import React , { Fragment , FC } from 'react' ; import useExperiment from './useExperiment' ; interface Props { id : string ; userId ? : string ; attributes ? : Record < string , any > ; } const Experiment = ( { id , userId , attributes , children } ) => { const variationId = useExperiment ( { id , userId , attributes } ) ; const variations = React . Children . map ( children , child => { if ( ! React . isValidElement ( child ) ) { return ; } return React . cloneElement ( child , { variationId } ) ; } ) ; return < Fragment > { variations } < /Fragment>; } ; export default Experiment ;