我正在使用react-router browserHistory
導航到路徑。導航到某個路徑後清除位置狀態
browserHistory.push({
pathname: '/mycomponent',
state: { someValue: 'value'},
});
所以這將導航到mycomponent。只要我到達我的組件,我想清除密鑰someValue
。所以當我刷新頁面時,它將不包含該值。
export class myComponent extends component {
componentWillMount() {
const value = this.props.location.state.someValue;
// clear state.someValue from history
}
}
任何幫助,將不勝感激。
據我所知'someValue'不會在位置狀態刷新頁面後。所以你不需要手動刪除它。 –