How do I clear location.state in react-router on page reload?

前端 未结 4 1857
余生分开走
余生分开走 2021-01-03 23:01

I am currently passing my state on route change like below:



        
4条回答
  •  礼貌的吻别
    2021-01-03 23:10

    After you used the state, dispatch an action with an empty state again to clean the state.

    this.props.dispatch(replace({
      ...this.props.location,
      state: undefined
    });
    

提交回复
热议问题