Closed zhex900 closed 2 years ago
You'll need to share some more code and/or clarify what are are try to do. It sounds like you want to render App
(presumably using react-testing-library
then use renderHook
to read the value of useHistory
from the other render.
If that is the case then I'm sorry, but that is not what this library is for. renderHook
renders the hook inside its own react tree so that you can test the hook in isolation of the component code. We do not share context or rendered component values with any other react tree by design (and I'm not sure it's technically possible either).
Thank you.
What is your question:
I want to use
useHistory
hook in my test.The problem is the
result
is got giving me the correct route. It seems like the mountedApp
and theuseHistory
hook in the test are using two different instances ofBrowserRouter
I want to reference
useHistory
hook inside the test. So I can know the current path and change routes.