我有一个特殊的用例,其中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
上有相同的信息。这里有什么选择?