withFormState.tsx 366 B

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