有没有一种方法可以让React Router Prompt知道位置在哪里

时间:2020-04-28 01:08:09

标签: reactjs react-router react-router-dom

我有一个特殊的用例,其中Prompt用于具有两条路径的父组件:/abc/bcd。我想允许Prompt在这两条路线之间移动而不会得到提示。

类似这样的东西。

<Prompt
  when={(nextLoc) => !["abc", "bcd"].includes(nextLoc) }
  message={"Are you sure you want to leave without saving your edits?"}
/>

我了解message拥有location信息。我需要在when上有相同的信息。这里有什么选择?

0 个答案:

没有答案