React history.push() not rendering new component

前端 未结 5 1166
梦谈多话
梦谈多话 2021-01-02 09:31

I have a React.js project with a simple sign in function. After the user is authorized, I call history.push method which changes the link in the address bar but does not ren

5条回答
  •  抹茶落季
    2021-01-02 09:32

    You need to apply withRouter to use this.props.history.push('/page') in every component that use "push"

    import { withRouter } from 'react-router-dom';
    .....
    export default
            withRouter(MoneyExchange);
    

    this is important when using push.

提交回复
热议问题