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

[Bug]: useCookieListener 的 handler 存在闭包调用,导致无法拿到最新数据 #495

Open
jin-sir opened this issue Sep 29, 2024 · 0 comments

Comments

@jin-sir
Copy link
Collaborator

jin-sir commented Sep 29, 2024

组件

cookie

版本

5.x

期望的结果

useEffect 的定时器中 compareValue->handler() 调用的 handler 是最新的。

实际的结果

image
image
使用 useEffect 开启定时器,在定时器中使用外部的compareValue方法,存在闭包问题,导致 compareValue 一直是最开始的,而compareValue中又调用了外部的handlerhandlercompareValue闭包了,导致handler中的所有数据都是最开始的状态,不是最新数据。

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