React router: 使用 Prompt 在路由状态变化时进行交互
在使用 react router 时,我们可以使用 history.listen() 在路由变化时进行一些操作,比如 dispatch action 这样的操作,那如果是需要交互提醒是否要跳转的情况呢?
答案是 Prompt.
根据官方文档,我们可以用下面的方式使用 Prompt:
<Prompt
when={formIsHalfFilledOut}
message="Are you sure you want to leave?"
/>
when: bool
Instead of c...
blog.lbj.moe1 min read