Closed AhmedElywa closed 5 years ago
Are you asking about making recursive propTypes?
yes need like this
Typically you’d do this by creating a custom propType function, but it’s pretty rare to need this.
Something like:
function recursive(...args) {
return PropTypes.oneOfType([
PropTypes.arrayOf(recursive),
PropTypes.shape({
...itemType,
children: recursive,
}),
])(...args);
};
Foo.PropTypes = {
items: recursive,
};
Thank you this work very good for me
function recursive(...args) {
return PropTypes.arrayOf(
PropTypes.shape({
...itemType,
children: recursive
})
)(...args);
}
Hello ,
i need to use same parent type inside it like typescript
in typeScript you can say
interface Parent { title: string, children: [Parent] | Parent[] }
now to use like this with PropTypes `
` any idea to use it in easy way
thank you