import React, { JSX } from 'react'; import { isRenderProps } from '../isRenderProps'; import { stringifyProps } from '../stringifyProps'; import { omit } from '../omit'; import { isEmpty } from '../isEmpty'; import { useStyles } from './Styles'; interface Props { children: JSX.Element; props: object; } export const StateProps: React.FC = ({ props, children }) => { const styles = useStyles(); const childrenProps = omit(children.props, ...Object.keys(props || {})); return (
{'<'} {children.type.displayName || children.type.name}{' '} {!isEmpty(props) && {stringifyProps(props)}}{' '} {!isRenderProps(children) && !isEmpty(childrenProps) && ( {stringifyProps(childrenProps)} )} {' />'}
); };