-
Notifications
You must be signed in to change notification settings - Fork 162
TypeError: Cannot read property 'history' of undefined #237
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
Comments
I've got the same thing...trying to port NavMenu.js from VS2017 to .tsx and getting the same error. Any chance you've gotten this working? |
Here is what I did - I went with a recommended react-router-dom instead which has a lot of support Firstly, you need a router for the navigation items (I put it in App.js)
And then in my Navbar.js component I used reactStrap bootstrap library:
|
I ran across this issue as well and for me it was related to my version of |
@ericgio I too am struggling with this same issue upgrading from 4.3.1 to 4.4.0 |
Hint: https://github.com/ReactTraining/react-router/releases/tag/v4.4.0-beta.0
|
I hacked a fix locally with tests passing. Haven't tested it yet beyond that: https://github.com/kfitzgerald/react-router-bootstrap/tree/context-fix I'll drop a PR if it fixes the issue. TL;DR: need to wrap the LinkContainer component with |
using React Router HooksYou can use useHistory hooks from react-router-dom inside a function component like this: Please note: You need to be using React >= 16.8 in order to use any of these hooks! |
TypeError: Cannot read property 'history' of undefined
LinkContainer.render
C:/Users/dd/Projects/vv/vv-app/node_modules/react-router-bootstrap/lib/LinkContainer.js:96
Struggling with using react-bootstrap and react-router-bootstrap. I created a basic navbar but no matter what (tried many examples online using a const in a file and a Component itself) but I get that error. Please help
The text was updated successfully, but these errors were encountered: