react-component / react-component/menu
二次封装时,无法获取到rc-menu中的context下发的值
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 701
- Forks
- 266
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 3
Description
我正在公司的组件库中封装Menu组件,是基于rc-menu进行的二次封装。现在有个逻辑是:在MenuItem被选中时,它所属的SubMenu的空心icon需要切换到选中态的实心icon,我发现在SubMenu中无法获取到它下属的MenuItem是否有被选中的。我尝试`import {PathUserContext} from 'rc-menu/lib/context/PathUserContext',但在使用React.useEffect(PathUserContext)无法获取到值。请教下我该如何能实现上述的切换逻辑?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading rc-menu/lib/context/PathUserContext and tracing how MenuItem and SubMenu use the context value. Reproduce the nested selection case described in the issue, then define and verify a supported way for SubMenu to know when a descendant MenuItem is selected and switch its icon accordingly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100