Skip to content

Commit ca18c03

Browse files
committed
update react 18
1 parent 1213443 commit ca18c03

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

package.json

+12-11
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,17 @@
4646
"install:react": "npm install --no-save react@${REACT_VERSION:-latest} react-dom@${REACT_VERSION:-latest} react-test-renderer@${REACT_VERSION:-latest}",
4747
"install:react-16.9.0": "cross-env REACT_VERSION=16.9.0 npm run install:react",
4848
"install:react-16": "cross-env REACT_VERSION=^16 npm run install:react",
49-
"install:react-17": "cross-env REACT_VERSION=^17 npm run install:react"
49+
"install:react-17": "cross-env REACT_VERSION=^17 npm run install:react",
50+
"install:react-18": "cross-env REACT_VERSION=^18 npm run install:react"
5051
},
5152
"dependencies": {
5253
"@babel/runtime": "^7.12.5",
5354
"react-error-boundary": "^3.1.0"
5455
},
5556
"devDependencies": {
56-
"@types/react": "17.0.44",
57-
"@types/react-dom": "17.0.15",
58-
"@types/react-test-renderer": "17.0.1",
57+
"@types/react": "^18.0.25",
58+
"@types/react-dom": "^18.0.9",
59+
"@types/react-test-renderer": "^18.0.0",
5960
"@typescript-eslint/eslint-plugin": "5.11.0",
6061
"@typescript-eslint/parser": "5.11.0",
6162
"all-contributors-cli": "6.20.0",
@@ -68,17 +69,17 @@
6869
"get-pkg-repo": "4.1.1",
6970
"kcd-scripts": "11.2.2",
7071
"prettier": "2.5.1",
71-
"react": "17.0.2",
72-
"react-dom": "17.0.2",
73-
"react-test-renderer": "17.0.2",
72+
"react": "^18.2.0",
73+
"react-dom": "^18.2.0",
74+
"react-test-renderer": "^18.2.0",
7475
"ts-node": "10.5.0",
7576
"typescript": "4.5.5"
7677
},
7778
"peerDependencies": {
78-
"@types/react": "^16.9.0 || ^17.0.0",
79-
"react": "^16.9.0 || ^17.0.0",
80-
"react-dom": "^16.9.0 || ^17.0.0",
81-
"react-test-renderer": "^16.9.0 || ^17.0.0"
79+
"@types/react": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^18.1.0",
80+
"react": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^18.1.0",
81+
"react-dom": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^18.1.0",
82+
"react-test-renderer": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^18.1.0"
8283
},
8384
"peerDependenciesMeta": {
8485
"@types/react": {

src/__tests__/useContext.test.tsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('useContext tests', () => {
1515
test('should get value from context provider', () => {
1616
const TestContext = createContext('foo')
1717

18-
const wrapper: React.FC = ({ children }) => (
18+
const wrapper: React.FC<{ children: React.ReactElement }> = ({ children }) => (
1919
<TestContext.Provider value="bar">{children}</TestContext.Provider>
2020
)
2121

@@ -29,7 +29,7 @@ describe('useContext tests', () => {
2929

3030
const value = { current: 'bar' }
3131

32-
const wrapper: React.FC = ({ children }) => (
32+
const wrapper: React.FC<{ children: React.ReactElement }> = ({ children }) => (
3333
<TestContext.Provider value={value.current}>{children}</TestContext.Provider>
3434
)
3535

@@ -45,18 +45,20 @@ describe('useContext tests', () => {
4545
test('should update value in context when props are updated', () => {
4646
const TestContext = createContext('foo')
4747

48-
const wrapper: React.FC<{ current: string }> = ({ current, children }) => (
49-
<TestContext.Provider value={current}>{children}</TestContext.Provider>
50-
)
48+
const wrapper: React.FC<{ current: string; children: React.ReactElement }> = ({
49+
current,
50+
children
51+
}) => <TestContext.Provider value={current}>{children}</TestContext.Provider>
5152

5253
const { result, rerender } = renderHook(() => useContext(TestContext), {
5354
wrapper,
5455
initialProps: {
55-
current: 'bar'
56+
current: 'bar',
57+
children: <div />
5658
}
5759
})
5860

59-
rerender({ current: 'baz' })
61+
rerender({ current: 'baz', children: <div /> })
6062

6163
expect(result.current).toBe('baz')
6264
})

0 commit comments

Comments
 (0)