Open
Description
Provide a general summary of the issue here
I'm trying to implement a menu using the useMenu
hook. This requires me to use a tree state.
To get the child nodes of a section, if I try to use item.childNodes
I get a deprecation warning. But the suggested alternative collection.getChildren(key)
isn't implemented for TreeCollection
. So as far as I can see there isn't currently any way of implementing this without triggering a warning.
🤔 Expected Behavior?
component below should show the O1 item:
function MyComponent() {
const treeState = useTreeState({
children: [<Section key="S1"><Item key="O1" /></Section>]
});
return (<pre>
{[...treeState.collection.getChildren('S1')]}
</pre>);
)
😯 Current Behavior
Component above crashes because getChildren
is not implemented
💁 Possible Solution
implement getChildren
on TreeCollection
, or un-deprecate childNodes
property on Node
interface
🔦 Context
I'm trying to implement a menu using the useMenu
hook.
🖥️ Steps to Reproduce
function MyComponent() {
const treeState = useTreeState({
children: [<Section key="S1"><Item key="O1" /></Section>]
});
return (<pre>
{[...treeState.collection.getChildren('S1')]}
</pre>);
)
Version
react-stately 3.36.1
What browsers are you seeing the problem on?
Chrome
If other, please specify.
No response
What operating system are you using?
Windows
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response