J
J
jspie2017-09-15 19:07:10
JavaScript
jspie, 2017-09-15 19:07:10

How to make NoMatch page on React-Router v4?

Hello, I can't figure out how to fix this situation... When using HashRouter. The NotFound page loads, but it's worth changing to BrowserRouter, as it writes to any incomprehensible url: cannot get / ..
App.jsx

import { 
    BrowserRouter as Router,
    Route,
    Switch,
    HashRouter
} from 'react-router-dom'

import Main from '../layouts/main/index'
import NotFound from '../layouts/404/index'

export default class App extends Component {
    render(){
        return<Router>
                <Switch>
                    <Route exact path="/" component = { Main }/>
                    <Route component = { NotFound }/>
                </Switch>
            </Router>
    }
}

I use express and webpack. I didn’t register a single request in Express, it seems to me that the matter is in express. How can it be solved?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Hazrat Hajikerimov, 2017-09-16
@hazratgs

Add path='*' to route not found

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question