CJY0208 / react-activation

Hack <KeepAlive /> for React
https://www.npmjs.com/package/react-activation
MIT License
1.78k stars 140 forks source link

react-router 跳转以后,组件内使用的 useContext 中的自定义hooks 中的 useState 值变化,但是组件不重新 render #315

Open evelope opened 3 months ago

evelope commented 3 months ago

首先,A页面 包裹了 KeepAlive。 A页面中的组件 使用 useContext,接受自定义hooks 中的 useState 暴露出来的值, 值变化 组件也会重新render。

然后A页面跳转了 B页面,再返回 A页面。

再次更改 自定义hooks 中的 useState 的值,

A页面中的组件 不会重新 render。

使用的 : "react": "^18.2.0", "react-activation": "^0.12.4",

添加 以下代码也不行: import { autoFixContext } from 'react-activation'

autoFixContext( [require('react/jsx-runtime'), 'jsx', 'jsxs', 'jsxDEV'], [require('react/jsx-dev-runtime'), 'jsx', 'jsxs', 'jsxDEV'] )