Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type Props = {
- children: Array<React.Element<any>> | React.Element<any>,
- };
- const children = this.props.children;
- if ( _.isArray(children) ) {
- return _.map(children, (child, key) => checkListComponent(child, key));
- }
- else if ( _.isObject(children) ) {
- return checkListComponent(children);
- }
- const checkListComponent = (child: React.Element<any>, key) => {
- return child.props.list
- ? React.cloneElement(child, key ? { options, key } : { options })
- : child;
- };
- return checkListComponent(children);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement