formContext.tsx 698 B

1234567891011121314151617181920212223242526272829
  1. import {createContext} from 'react';
  2. import FormModel from 'sentry/components/forms/model';
  3. /**
  4. * Context type used in 'settings' forms.
  5. *
  6. * These differ from the 'old' forms in that they use mobx observers
  7. * to update state and expose it via the `FormModel`
  8. */
  9. export type FormContextData = {
  10. /**
  11. * The default value is undefined so that FormField components
  12. * not within a form context boundary create MockModels based
  13. * on their props.
  14. */
  15. form?: FormModel;
  16. /**
  17. * Should fields do save requests on blur?
  18. */
  19. saveOnBlur?: boolean;
  20. };
  21. const FormContext = createContext<FormContextData>({
  22. form: undefined,
  23. saveOnBlur: undefined,
  24. });
  25. export default FormContext;