alibaba / alibaba/hooks

关于 useSetState 返回值中的第二个参数没有用 useMemoriedFn 包裹产生的问题

Open
#2,583 1 comment 0 reactions 0 assignees View on GitHub
pr welcomed
Dominant language
TypeScript
Stars
15k
Forks
2.8k
Avg merge
15h 7m
Merged PRs (30d)
2

Description

企业微信截图_8b59d200-7e15-4019-9b7d-47c0e65cccbb
如图,在 useMemo / useEffect / useCallback 中使用 useSetState 的时候,eslint 会提示需要把 setState 作为依赖。
查阅源码发现这块的返回值并没有用 useMemoriedFn 包裹。希望能在新版本改善

Contributor guide

Open the contributing guide

Research direction

Start by reading the useSetState implementation and inspect how its returned second function is created. Check the existing tests for useSetState and add coverage for using that function in useMemo, useEffect, or useCallback without an unnecessary dependency warning. Done means the returned function has stable memoized behavior and the relevant tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.