![](/img/trans.png)
[英]Delete redux state on navigating to a different route in react-redux application?
[英]clear state of redux when navigating to different route
我的login.js中有此密码,我尝试使用错误的密码来触发它。
{this.props.msg && <MessageBanner content={this.props.msg} />}
但是,当消息出现时,我尝试导航至signup.js,该文件也具有相同的功能
{this.props.msg && <MessageBanner content={this.props.msg} />}
该消息不会消失。 或者我在signup.js页面中,使错误出现,我在浏览器上单击回来,该错误没有消失。
无论如何在使用react-router导航时清除状态?
听起来您需要正确设置“切换”系统才能显示此错误消息...
您的MessageBanner是否有关闭按钮? 如果是这样,您将希望附加一个
onClick={this.setState=({toggleErrorMessage: !this.state.toggleErrorMessage})}
//点击反转时,此this.state.toggleErrorMessage当前是什么... //因此,如果当前为true,则单击后为false。
然后,您可以做更多类似的事情。
{this.state.toggleErrorMesage ? this.props.msg && <MessageBanner content={this.props.msg} /> : undefined }
//如果toggleErrorMessage为true,则显示味精和横幅...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.