react-component / react-component/tree-select
TreeNode Generic
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 312
- Forks
- 204
- Avg merge
- 37m
- Merged PRs (30d)
- 1
Description
Currently TreeNode does not accept a generic for its value prop.
So the value is always type string | number.
However TreeSelect accepts a generic and defaults the type to DefaultValueType (RawValueType or RawValueType[])
I'd expect the following generic to work
type MyCustomValueType = "yes" | "no";
class App extends React.Component {
render() {
return (
<TreeSelect<MyCustomValueType>>
<TreeNode<MyCustomValueType> value="yes" title="yes" />
<TreeNode<MyCustomValueType> value="no" title="no" />
<TreeNode<MyCustomValueType> value="ts error" title="no" /> {/* Throws TS error */}
</TreeSelect>
);
}
}
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 with the TreeNode definition in src/TreeNode.tsx and compare its value prop with the generic handling in src/TreeSelect.tsx around line 613. Check how the provided TypeScript example is typed, including the invalid "ts error" value. Done means custom TreeNode and TreeSelect generics accept valid values and reject invalid ones.
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