useUrlState 增加是否启用参数
- Dominant language
- TypeScript
- Stars
- 15k
- Forks
- 2.8k
- Avg merge
- 15h 7m
- Merged PRs (30d)
- 2
Description
场景:业务中需要封装一个表单,该表单在一个页面可能出现两次(例如页面和弹窗里都有复用该表单),如果都 pushState 就错乱了,所以希望业务可选这个参数,是否启用 pushState 功能,当 allowPushState = false 时,其效果和 react useState 一致。由于 react hooks 限制,写 const [] = allowPushState ? useUrlState : useState 这种写法是不允许的,做额外的封装又产生多余的代码
诉求:希望 option 能增加一个参数 allowPushState,表示是否启用这一 pushState 的 feature
修改:update(); 改成
update();
if (options?.allowPushState = false) return;
Contributor guide
Research direction
Start by locating the useUrlState entry point and its update() path, then inspect how options are handled and whether related tests exist. Add an allowPushState option so false matches useState behavior without pushState while the default remains unchanged; done when both modes are covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100