1

This is my code:

class noMatch extends React.Component {
  render() {
    return 'Not Found'
  }
}
ReactDOM.render(
   <BrowserRouter>
      <Switch>
        <Route exact path='/(index.html)?' component={App}/>
        <Route component={noMatch}/>
      </Switch>
    </BrowserRouter>,
  mountNode
);

The app runs in localhost:3000/ and localhost:3000/index.html as expected. but when there's no match, my no Match doesnt render? I am following the noMatch tutorial from the docs here. Help?

gpbaculio
  • 5,693
  • 13
  • 60
  • 102

1 Answers1

0

Your router code looks find. If you are just returning string in your noMatch component, you should return valid React element such as this:

class noMatch extends React.Component {
    render() {
        return (
            <div>Not Found</div>
        );
    }
}
sam
  • 2,780
  • 1
  • 17
  • 30