I have this code:
render() {
return (
<BrowserRouter>
<React.Fragment>
<Navbar inverse collapseOnSelect>
<Nav className='float_right'>
<React.Fragment>
<LinkContainer to='/about'>
<NavItem>
About us
</NavItem>
</LinkContainer>
</React.Fragment>
</Nav>
</Navbar>
<Switch>
<Route exact path='/about' component={AboutComponent}/>
<Route exact path='/' component={HomeComponent}/>
</Switch>
</React.Fragment>
</BrowserRouter>
);
}
And I'm trying to make a simple navigation. But I'm getting an error saying:
TypeError: this.context.router is undefined
Why is that? I checked the docs and searched for the answer, but all I found was to add something with the context to the constructor, like
constructor(props,context){
super(props,context);
}
This started happening when I added <LinkContainer/>
to the code
Which just didn't work. Any ideas how to solve this?