Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
evelope opened this issue May 16, 2024 · 0 comments

Comments

@evelope
Copy link

evelope commented May 16, 2024

首先,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']
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant