UNPKG

@nomios/web-uikit

Version:
19 lines (16 loc) 551 B
import _castArray from "lodash/castArray"; import { Fragment } from 'react'; import FlowModalStep from '../FlowModalStep'; const flatContentsChildren = children => _castArray(children).reduce((acc, item) => { if (item) { if (item.type === Fragment) { acc.push(...flatContentsChildren(item.props.children)); } else if (item.type === FlowModalStep) { acc.push(item); } else { console.error('FlowModal only accepts children of type <FlowModalStep>'); } } return acc; }, []); export default flatContentsChildren;