You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot
When I do:
import{renderHook}from'@testing-library/react-hooks'import{someHook}from'../'test('...',()=>{const{ result }=renderHook(()=>someHook())})
The screenshot below shows a barebones test using @testing-library/react-hooks without any gimmicks and it throws a warning.
Notice that I do not get this warning when using @testing-library/react. The screenshot below shows a barebones component that uses a hook and doesn't throw a warning.
The text was updated successfully, but these errors were encountered:
import{renderHook}from'@testing-library/react'// <-- NOWtest('returns logged in user',()=>{const{ result }=renderHook(()=>useLoggedInUser())expect(result.current).toEqual({name: 'Alice'})})
What is your question:
Is there a way to remove the
Warning: ReactDOM.render is no longer supported in React 18.
warning from@testing-library/react-hooks -> renderHook
?Related PRs:
As suggested in some blog posts and some GitHub issues, I upgraded react-testing library to support React 18 createRoot:
But I keep getting this warning:
Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot
When I do:
The screenshot below shows a barebones test using
@testing-library/react-hooks
without any gimmicks and it throws a warning.Notice that I do not get this warning when using
@testing-library/react
. The screenshot below shows a barebones component that uses a hook and doesn't throw a warning.The text was updated successfully, but these errors were encountered: