Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support react 19 on pglite-react and pglite-repl #484

Merged
merged 6 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tasty-apples-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@electric-sql/pglite-repl': patch
---

Bump versions of React, React DOM, and related testing libraries to v19 on pglite-repl. The PGlite REPL now supports React v18 and v19 projects.
5 changes: 5 additions & 0 deletions .changeset/tough-wombats-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@electric-sql/pglite-react': patch
---

Bump versions of React, React DOM, and related testing libraries to v19 on pglite-react. pglite-react now supports React v18 and v19 projects.
12 changes: 6 additions & 6 deletions packages/pglite-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@
"@electric-sql/pglite": "workspace:*",
"@eslint-react/eslint-plugin": "^1.14.3",
"@testing-library/dom": "^10.4.0",
"@testing-library/react": "^16.0.1",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.0",
"@testing-library/react": "^16.1.0",
"@types/react": "^19.0.2",
"@types/react-dom": "^19.0.2",
"@vitejs/plugin-react": "^4.3.2",
"eslint-plugin-react-compiler": "0.0.0-experimental-9ed098e-20240725",
"globals": "^15.11.0",
"jsdom": "^24.1.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"vitest": "^2.1.2"
},
"peerDependencies": {
"@electric-sql/pglite": "workspace:^",
"react": "^18.0.0"
"react": "^18.0.0 || ^19.0.0 || ^19.0.0-rc"
}
}
2 changes: 1 addition & 1 deletion packages/pglite-react/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function useLiveQueryImpl<T = { [key: string]: unknown }>(
): Omit<LiveQueryResults<T>, 'affectedRows'> | undefined {
const db = usePGlite()
const paramsRef = useRef(params)
const liveQueryRef = useRef<LiveQuery<T> | undefined>()
const liveQueryRef = useRef<LiveQuery<T> | undefined>(undefined)
let liveQuery: LiveQuery<T> | undefined
let liveQueryChanged = false
if (!(typeof query === 'string') && !(query instanceof Promise)) {
Expand Down
4 changes: 3 additions & 1 deletion packages/pglite-react/src/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ interface Props<T extends PGliteWithLive> {
db?: T
}

type PGliteProvider<T extends PGliteWithLive> = (props: Props<T>) => JSX.Element
type PGliteProvider<T extends PGliteWithLive> = (
props: Props<T>,
) => React.JSX.Element
type UsePGlite<T extends PGliteWithLive> = (db?: T) => T

interface PGliteProviderSet<T extends PGliteWithLive> {
Expand Down
8 changes: 4 additions & 4 deletions packages/pglite-repl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"@uiw/codemirror-themes": "^4.23.5",
"@uiw/react-codemirror": "^4.23.5",
"psql-describe": "^0.1.5",
"react": "^18.3.1",
"react-dom": "^18.3.1"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"peerDependencies": {
"@electric-sql/pglite": "workspace:^"
Expand All @@ -64,8 +64,8 @@
"devDependencies": {
"@electric-sql/pglite": "workspace:^",
"@types/node": "^20.16.11",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.0",
"@types/react": "^19.0.2",
"@types/react-dom": "^19.0.2",
"@vitejs/plugin-react": "^4.3.2",
"eslint-plugin-react-compiler": "0.0.0-experimental-9ed098e-20240725",
"eslint-plugin-react-hooks": "^4.6.2",
Expand Down
5 changes: 1 addition & 4 deletions packages/pglite-repl/src/Repl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,7 @@ export function Repl({
`}
style={styles}
>
<div
className="PGliteRepl-output"
ref={(ref) => (outputRef.current = ref)}
>
<div className="PGliteRepl-output" ref={outputRef}>
{loading && <div className="PGliteRepl-loading-msg">Loading...</div>}
{output.map((response) => (
<div key={`${response.query}-${response.time}`}>
Expand Down
113 changes: 74 additions & 39 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.