I want to link from one React page to another on a static site, but my routes keep linking to /#/info which doesn't seem to do anything.
my index.js file:
ReactDOM.render(<App />, document.getElementById('root')); My App.js file:
import React from 'react' import { HashRouter, Switch, Route, Link } from 'react-router-dom' import Stream from './Stream.js' import Info from './Info.js' function App() { return ( <HashRouter> <Switch> <Route exact path='/' component='Stream' /> <Route path='/info' component='Info' /> </Switch> <Link to='/info'>Info</Link> <Stream /> </HashRouter> ); } export default App; My Stream.js:
import React from 'react' function Stream() { return ( <div>Stream</div> ); } export default Stream; My Info.js:
import React from 'react' import { Switch, Route } from 'react-router-dom' function Info() { return ( <h1>Info</h1> ); } export default Info; According to this the url being rewritten as /#/info is expected behavior, but my content is not loading when the link is clicked. I want <Stream /> to go away and for the contents of <Info /> to take its place.