You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Despite #193 claiming it fixed this issue, installing 2.10.0 reveals that:
<TreeView<CustomMetaDataType> /> is not possible
<TreeView data={myFlatListOfTypedItems} nodeRenderer={(element) => (...)} /> doesn't infer the type from my items and enforces the default type for metadata.
exportinterfaceTreeviewComponentRef{foo: VoidFunction;}// existing types for tree view props. no change neededexporttypeITreeViewProps<MextendsIFlatMetadata=IFlatMetadata>={ ... }// 1. define component outside of forwardRefconstTreeViewComponent=<T,>(props: ITreeViewProps<T>,ref: Ref<TreeviewComponentRef>)=>{...};// 2. export the forwardRef, with an enforced type generic and return type.constTreeView=forwardRef(TreeViewComponent)as<T>(props: ITreeViewProps<T>&{ref?: Ref<TreeviewComponentRef>})=>ReturnType<typeofTreeViewComponent>;// example using it.exportconstMyAmazingApp=()=>{return(<TreeView<{yes: false}>data={[]}nodeRenderer={(element)=>console.log(data.metadata.yes===false)}/>);};
However, I'm not smart enough to work out how to make this work with your use of propTypes (i haven't used that concept for nearly 6 years now)
To Reproduce
Steps to reproduce the behavior:
Go to '...'
Click on '....'
Scroll down to '....'
See error
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
OS: [e.g. iOS]
Browser [e.g. chrome, safari]
Version [e.g. 22]
Smartphone (please complete the following information):
Device: [e.g. iPhone6]
OS: [e.g. iOS8.1]
Browser [e.g. stock browser, safari]
Version [e.g. 22]
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
Describe the bug
Despite #193 claiming it fixed this issue, installing
2.10.0
reveals that:<TreeView<CustomMetaDataType> />
is not possible<TreeView data={myFlatListOfTypedItems} nodeRenderer={(element) => (...)} />
doesn't infer the type from my items and enforces the default type for metadata.the
index.d.ts
has this at the bottom:Which basically just decides it doesn't care what kind of pizza you ordered, you're getting a Margherita.
Screencast.from.2024-12-23.19-13-30.mp4
Where my
TocLeaf
looks likeCode That Causes The Issue
When using forward ref and expecting to allow others to utilise the generic type parameter, you need to do two things:
forwardRef
function, instead define it outside with two parameters:props
, andref
forwardRef
that is typecast with the return value of function in1.
:So to put this in context:
However, I'm not smart enough to work out how to make this work with your use of propTypes (i haven't used that concept for nearly 6 years now)
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: