react-activation icon indicating copy to clipboard operation
react-activation copied to clipboard

KeepAlive中的自定义属性更新无法触发cachingNodes更新

Open wkeylin opened this issue 2 years ago • 0 comments

function AliveItem(props) {
  const id = props.match.params.id
  const [query, setQuery] = useState()
  const shared = id % 2 === 0

  // 双数共享同一份缓存
  // 单数独享缓存
  return (
    <>
      <button onClick={() => setQuery('?name=test')}>Set Query</button>
      <KeepAlive
        query={query || '?name=demo'}
        name={shared ? 'ItemShared' : `Item${id}`}
        id={shared ? undefined : id}
      >
        <Item {...props} />
      </KeepAlive>
    </>
  )
}

如上代码所示,希望在更新query字段时,可以触发cachingNodes更新

复现示例:https://codesandbox.io/s/ke-guan-bi-de-yi-fang-wen-lu-you-tab-shi-li-ke-an-lu-you-can-shu-fen-duo-fen-huan-cun-forked-9o0w0b?file=/src/App.js

wkeylin avatar Dec 07 '22 08:12 wkeylin