Skip to content

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

@jin-sir

Description

@jin-sir

组件

cookie

版本

5.x

期望的结果

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

实际的结果

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions