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

withRouter deprecated, replaced with Navigate and getting useContext error for Register.js #36

Open
gregoryekhator opened this issue Jun 28, 2023 · 0 comments

Comments

@gregoryekhator
Copy link

Hi Rishi and all,

First of all thanks, so much for this tutorial.

My challenge is it is 4 years old and we are now using react-router v6 with some deprecations including withRouter which you implement in this MERN-AUTH tutorial.

I am getting withRouter deprecated,
So i replaced with Navigate for register.js here:

export default connect(
mapStateToProps,
{ registerUser }
)(Navigate(Register));

and I get this error getting useContext error on Register.js

Cannot read properties of null (reading 'useContext')
TypeError: Cannot read properties of null (reading 'useContext')
at Object.useContext (http://localhost:3000/static/js/bundle.js:47601:25)
at useInRouterContext (http://localhost:3000/static/js/bundle.js:43805:45)
at Navigate (http://localhost:3000/static/js/bundle.js:44689:4)

Note: I am really after the banking tutorial, but since it relies on this one, i had to do this one first.

Any chance of updating this MERN-AUTH tutorial, and the banking tutorial for 2023 react/typescript/node specs for compatibility with react-router version 6 and what else could trigger errors?

Many thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant