withFormApi.tsx 350 B

1234567891011
  1. import React from 'react';
  2. import { FormApiContext } from '../context';
  3. const withFormApi = (Component: React.ElementType) =>
  4. React.forwardRef((props, ref) => (
  5. <FormApiContext.Consumer>
  6. {formApi => <Component formApi={formApi} ref={ref} {...props} />}
  7. </FormApiContext.Consumer>
  8. ));
  9. export default withFormApi;