history.push(‘/dashboard’) is updating the url but not navigating to it?

There are any questions like this in stackoverflow. But I am not able to find … Read more history.push(‘/dashboard’) is updating the url but not navigating to it?

There are any questions like this in stackoverflow. But I am not able to find a solution.

Here is part of my my index.js

ReactDOM.render(
<BrowserRouter>
 <Provider store={store}>
   <Login />
 </Provider>
</BrowserRouter>,
document.getElementById('root')
);

This is part of my Login component

export default function BasicExample() {
 return (
 <Router>
  <Switch>
    <Route exact path="/dashboard" component={Dashboard}>
      <Dashboard />
    </Route>
    ........
  </Switch>
  </Router>
 )
}

const Login = () => {
  function handleLogin (e) {
     .....
     history.push("/dashboard");
     .....
  }
}

I don’t know what is wrong. I am using react-admin template. Can anyone help?

Source: React – Stack Overflow


Categories: NewsTags: ,

Leave a Reply

Your email address will not be published. Required fields are marked *