Skip to content

Commit 52bed4a

Browse files
authored
Merge pull request #607 from formio/FIO-9881-React19-upgrade
FIO-9881: upgrated up to React19
2 parents ac96c69 + 71918a4 commit 52bed4a

File tree

8 files changed

+161
-200
lines changed

8 files changed

+161
-200
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,27 @@ npm install @formio/js --save
1717
yarn add @formio/react @formio/js
1818
```
1919

20+
## Usage with Vite (Note: When using frameworks like Next.js or Create React App, no extra Vite configuration is necessary)
21+
22+
When using @formio/react in a project built with Vite (especially for React 18 and 19), make sure you install the @vitejs/plugin-react package and configure it in your vite.config.js file.
23+
24+
Install Vite React Plugin
25+
26+
```bash
27+
yarn add --dev @vitejs/plugin-react
28+
```
29+
30+
In your vite.config.js, add the React plugin:
31+
32+
```bash
33+
import { defineConfig } from 'vite';
34+
import react from '@vitejs/plugin-react';
35+
36+
export default defineConfig({
37+
plugins: [react()],
38+
});
39+
```
40+
2041
## Hooks
2142
2243
### useFormioContext

package.json

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@
3434
"prop-types": "^15.8.1"
3535
},
3636
"devDependencies": {
37-
"@formio/core": "2.2.2-rc.5",
38-
"@formio/js": "5.0.0-rc.76",
39-
"@testing-library/jest-dom": "^6.4.2",
40-
"@testing-library/react": "^14.2.2",
37+
"@formio/core": "^2.4.0",
38+
"@formio/js": "^5.1.1",
39+
"@testing-library/dom": "^10.4.0",
40+
"@testing-library/jest-dom": "^6.6.2",
41+
"@testing-library/react": "^16.1.1",
4142
"@types/jest": "^29.5.12",
4243
"@types/lodash": "^4.14.202",
43-
"@types/react": "^18.2.55",
44+
"@types/react": "^19.0.0",
4445
"@types/ungap__structured-clone": "^1.2.0",
4546
"@typescript-eslint/eslint-plugin": "^7.0.1",
4647
"@typescript-eslint/parser": "^7.0.1",
@@ -56,8 +57,8 @@
5657
"jest-transform-css": "^6.0.1",
5758
"jsdom": "^22.1.0",
5859
"prettier": "3.2.4",
59-
"react": "^18.1.0",
60-
"react-dom": "^18.1.0",
60+
"react": "^19.0.0",
61+
"react-dom": "^19.0.0",
6162
"ts-jest": "^29.1.2",
6263
"ts-node": "^10.9.2",
6364
"tsc": "^2.0.4",
@@ -68,9 +69,9 @@
6869
"lib"
6970
],
7071
"peerDependencies": {
71-
"@formio/core": "2.2.2-rc.5",
72-
"@formio/js": "5.0.0-rc.76",
73-
"react": "^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.1.0",
74-
"react-dom": "^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.1.0"
72+
"@formio/core": "2.4.0",
73+
"@formio/js": "5.1.1",
74+
"react": "^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.1.0 || ^19.0.0",
75+
"react-dom": "^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.1.0 || ^19.0.0"
7576
}
7677
}

src/components/FormEdit.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,19 @@ const DEFAULT_INITAL_FORM = {
3838
path: '',
3939
display: 'form' as const,
4040
type: 'form' as const,
41-
components: [{
42-
type: 'button',
43-
label: 'Submit',
44-
key: 'submit',
45-
size: 'md',
46-
block: false,
47-
action: 'submit',
48-
disableOnInvalid: true,
49-
theme: 'primary'
50-
}],
41+
components: [
42+
{
43+
type: 'button',
44+
label: 'Submit',
45+
key: 'submit',
46+
size: 'md',
47+
block: false,
48+
action: 'submit',
49+
disableOnInvalid: true,
50+
theme: 'primary',
51+
input: true,
52+
},
53+
],
5154
};
5255

5356
export const DEFAULT_SETTINGS_FORM = {
@@ -124,7 +127,7 @@ export const DEFAULT_SETTINGS_FORM = {
124127
{
125128
label: 'Wizard',
126129
value: 'wizard',
127-
}
130+
},
128131
],
129132
},
130133
validate: {
@@ -243,7 +246,7 @@ export const FormEdit = ({
243246
onSaveForm?.(form);
244247
} catch (error) {
245248
console.error('Error saving form', error);
246-
setError(error as ErrorObject) ;
249+
setError(error as ErrorObject);
247250
}
248251
};
249252

src/components/FormGrid.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Form as FormType } from '@formio/core';
33
import { usePagination } from '../hooks/usePagination';
44
import { JSON } from './Form';
55
import { ReactNode, useCallback } from 'react';
6+
import type { JSX } from 'react';
67

78
export type Action = {
89
name: string;

src/components/__tests__/Form.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { render, screen } from '@testing-library/react';
1+
import { render } from '@testing-library/react';
2+
import { screen } from '@testing-library/dom';
23
import '@testing-library/jest-dom';
34

45
import { Form } from '../Form';
@@ -25,6 +26,7 @@ const simpleForm = {
2526
label: 'Submit',
2627
type: 'button',
2728
key: 'submit',
29+
input: true,
2830
disableOnInvalid: true,
2931
},
3032
],

src/hooks/__tests__/usePagination.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { renderHook, waitFor } from '@testing-library/react';
1+
import { renderHook } from '@testing-library/react';
2+
import { waitFor } from '@testing-library/dom';
23
import { usePagination } from '../usePagination';
34

45
it('should return correct paginated data when passed a static array', () => {

tsconfig.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
"esModuleInterop": true,
1414
},
1515
"include": ["src/**/*"],
16-
"types": ["node", "jest", "@testing-library/jest-dom"],
16+
"types": [
17+
"node",
18+
"jest",
19+
"@testing-library/jest-dom",
20+
"react",
21+
"react-dom",
22+
],
1723
"exclude": ["node_modules", "lib", "test"],
1824
}

0 commit comments

Comments
 (0)