Hi all , i love the Tutorals and have been teaching me to much, but once i got to
Adding Links in the Navbar - step import { LinkContainer } from “react-router-bootstrap”;
and do npm start all i get is a website with errors
TypeError: Cannot read property ‘history’ of undefined
I had the same issue, it comes from a change in react-router-dom.
To get around it import withRouter from react-router-dom, and use it to wrap the LinkContainer components.
So I created a separate component in RoutedLinkContainer.js.
import React from "react";
import { LinkContainer } from "react-router-bootstrap";
import { NavItem } from "react-bootstrap";
import { withRouter } from "react-router-dom";
function RoutedLinkContainer(props) {
return (
<LinkContainer to={props.link}>
<NavItem>{props.displayText}</NavItem>
</LinkContainer>
);
}
export default withRouter(RoutedLinkContainer);
In App.js import RoutedLinkContainer at the top, and replace the lines: