tree-select
tree-select copied to clipboard
TreeNode Generic
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>
);
}
}