alibaba / alibaba/hooks

[REQUEST] useSelections能否直接传入useState返回的值/暴露操作方法

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

Description

背景
- 有个const [state, setState] = useControllableValue({onChange})
- 涉及选择操作
- 现在useSelections只能把state传进去,但是setState没办法传,这就导致我改了state,但是没办法通知外部组件
- 如果在写个useEffect(() => {onChange(selected)}, [selected]);又非常麻烦和奇怪

所以希望能否

1. 支持把 useSelections(useControllableValue({onChange})) 这种写法和能力,这样写起来就很简单
2. 或者暴露出里面操作方法,变成 withMethods(useControllableValue({onChange})), 这样也比较方便

Contributor guide

Open the contributing guide

Research direction

Start by reading the useSelections and useControllableValue hook entry points to understand their current inputs and change flow. Compare the requested direct integration with the alternative of exposing operations; done means selection changes can notify the external onChange handler without requiring an extra useEffect.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.