I got such an error when I try to use react-router:
Here's the code :
import React from 'react'
import { render } from 'react-dom'
import { BrowserRouter, Match } from 'react-router'
import Landing from './Landing'
import 'bootstrap/dist/css/bootstrap.css'
const App = React.createClass({
render () {
return (
<BrowserRouter>
<div className='app'>
<Match exactly pattern='/' component={Landing} />
</div>
</BrowserRouter>
)
}
})
render(<App />, document.getElementById('app'))
Landing.js:
import React from 'react'
import Navigation from './Navigation'
const Landing = React.createClass({
render () {
return (
<Navigation />
)
}
})
export default Landing
The Navigation.js code:
import React from 'react'
import {Link} from 'react-router'
import {Collapse, NavbarToggler, Navbar, NavbarBrand, Nav, NavItem, NavLink} from 'reactstrap'
class Navigation extends React.Component {
constructor (props) {
super(props)
this.toggle = this.toggle.bind(this)
this.state = {
isOpen: false
}
}
toggle () {
this.setState({
isOpen: !this.state.isOpen
})
}
render () {
return (
<div>
<Navbar color='faded' light toggleable>
<NavbarToggler right onClick={this.toggle} />
<NavbarBrand href='/'>reactstrap</NavbarBrand>
<Collapse isOpen={this.state.isOpen} navbar>
<Nav className='ml-auto' navbar>
<NavItem>
<NavLink tag={Link} to='https://github.com/reactstrap/reactstrap'>Components</NavLink>
</NavItem>
<NavItem>
<NavLink tag={Link} to='https://github.com/reactstrap/reactstrap'>Github</NavLink>
</NavItem>
</Nav>
</Collapse>
</Navbar>
</div>
)
}
}
export default Navigation
The reason I think the problem is in router is because without router it renders well.
From package.json: "react-router": "4.0.0-beta.4"