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

update react 18 #927

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ library will instead be included as official additions to both `react-testing-li
([PR](https://github.com/callstack/react-native-testing-library/pull/923)) with the intention being
to provide a more cohesive and consistent implementation for our users.

Please be patient as we finalise these changes in the respective testing libraries.
In the mean time you can install `@testing-library/react@^13.1`
Please be patient as we finalise these changes in the respective testing libraries. In the mean time
you can install `@testing-library/react@^13.1`

## Table of Contents

Expand Down Expand Up @@ -279,6 +279,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center"><a href="https://www.facebook.com/masoud.bonabi"><img src="https://avatars.githubusercontent.com/u/6429009?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Masious</b></sub></a><br /><a href="https://github.com/testing-library/react-hooks-testing-library/commits?author=masious" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/Laishuxin"><img src="https://avatars.githubusercontent.com/u/56504759?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Laishuxin</b></sub></a><br /><a href="https://github.com/testing-library/react-hooks-testing-library/commits?author=Laishuxin" title="Documentation">📖</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/joazco"><img src="https://avatars.githubusercontent.com/u/106530115?v=4?s=100" width="100px;" alt=""/><br /><sub><b>joazco</b></sub></a><br /><a href="https://github.com/testing-library/react-hooks-testing-library/commits?author=joazco" title="Code">💻</a></td>
</tr>
</table>

<!-- markdownlint-restore -->
Expand Down
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,17 @@
"install:react": "npm install --no-save react@${REACT_VERSION:-latest} react-dom@${REACT_VERSION:-latest} react-test-renderer@${REACT_VERSION:-latest}",
"install:react-16.9.0": "cross-env REACT_VERSION=16.9.0 npm run install:react",
"install:react-16": "cross-env REACT_VERSION=^16 npm run install:react",
"install:react-17": "cross-env REACT_VERSION=^17 npm run install:react"
"install:react-17": "cross-env REACT_VERSION=^17 npm run install:react",
"install:react-18": "cross-env REACT_VERSION=^18 npm run install:react"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will need to update the matrix here for it to run on CI.

},
"dependencies": {
"@babel/runtime": "^7.12.5",
"react-error-boundary": "^3.1.0"
},
"devDependencies": {
"@types/react": "17.0.44",
"@types/react-dom": "17.0.15",
"@types/react-test-renderer": "17.0.1",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.9",
"@types/react-test-renderer": "^18.0.0",
"@typescript-eslint/eslint-plugin": "5.11.0",
"@typescript-eslint/parser": "5.11.0",
"all-contributors-cli": "6.20.0",
Expand All @@ -68,17 +69,17 @@
"get-pkg-repo": "4.1.1",
"kcd-scripts": "11.2.2",
"prettier": "2.5.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-test-renderer": "17.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-test-renderer": "^18.2.0",
"ts-node": "10.5.0",
"typescript": "4.5.5"
},
"peerDependencies": {
"@types/react": "^16.9.0 || ^17.0.0",
"react": "^16.9.0 || ^17.0.0",
"react-dom": "^16.9.0 || ^17.0.0",
"react-test-renderer": "^16.9.0 || ^17.0.0"
"@types/react": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^18.1.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^18.1.0",
"react-dom": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^18.1.0",
"react-test-renderer": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^18.1.0"
Comment on lines +79 to +82
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these could just be ^16.9.0 || ^17.0.0 || ^18.0.0 as ^18.1.0 is covered by the ^ on 18.0.0.

},
"peerDependenciesMeta": {
"@types/react": {
Expand Down
16 changes: 9 additions & 7 deletions src/__tests__/useContext.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('useContext tests', () => {
test('should get value from context provider', () => {
const TestContext = createContext('foo')

const wrapper: React.FC = ({ children }) => (
const wrapper: React.FC<{ children: React.ReactElement }> = ({ children }) => (
<TestContext.Provider value="bar">{children}</TestContext.Provider>
)

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

const value = { current: 'bar' }

const wrapper: React.FC = ({ children }) => (
const wrapper: React.FC<{ children: React.ReactElement }> = ({ children }) => (
<TestContext.Provider value={value.current}>{children}</TestContext.Provider>
)

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

const wrapper: React.FC<{ current: string }> = ({ current, children }) => (
<TestContext.Provider value={current}>{children}</TestContext.Provider>
)
const wrapper: React.FC<{ current: string; children: React.ReactElement }> = ({
current,
children
}) => <TestContext.Provider value={current}>{children}</TestContext.Provider>

const { result, rerender } = renderHook(() => useContext(TestContext), {
wrapper,
initialProps: {
current: 'bar'
current: 'bar',
children: <div />
}
})

rerender({ current: 'baz' })
rerender({ current: 'baz', children: <div /> })

expect(result.current).toBe('baz')
})
Expand Down