How to use the @uform/core.createForm function in @uform/core

To help you get started, we’ve selected a few @uform/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alibaba / uform / packages / react / src / __tests__ / useForm.spec.tsx View on Github external
test('FormState change', ()=>{
    const broadCastWrapper = ({ children }) => {
      return {children}
    }

    const form = createForm({})
    expect(form.getFormState(state => state.mounted)).toEqual(false)
    expect(form.getFormState(state => state.initialized)).toEqual(true)
    expect(form.getFormState(state => state.editable)).toEqual(undefined)
    const { result } = renderHook(() => useForm({ form }), { wrapper: broadCastWrapper })
    expect(result.current.getFormState(state => state.mounted)).toEqual(true)
    expect(result.current.getFormState(state => state.initialized)).toEqual(true)
    expect(result.current.getFormState(state => state.editable)).toEqual(undefined)
  })
github alibaba / uform / packages / react / src / __tests__ / useForm.spec.tsx View on Github external
test('return createForm instance', ()=>{
    const broadCastWrapper = ({ children }) => {
      return {children}
    }

    const opts = {}
    const form = createForm(opts)
    const { result } = renderHook(() => useForm({ form }), { wrapper: broadCastWrapper })
    expect(result.current).toEqual(form)
  })
github alibaba / uform / packages / react / src / hooks / useForm.ts View on Github external
const form = useMemo(() => {
    return alreadyHaveForm ? options.form : createForm(options)
  }, [])
github alibaba / uform / packages / react / src / state / form.tsx View on Github external
constructor(props) {
      super(props)
      this.initialized = false
      this.form = createForm({
        initialValues: props.defaultValue || props.initialValues,
        values: props.value,
        effects: props.effects,
        subscribes: props.subscribes,
        schema: props.schema,
        editable: props.editable,
        traverse: schema => {
          const traverse =
            schema &&
            getFormFieldPropsTransformer(schema['x-component'] || schema.type)
          return traverse ? traverse(schema) : schema
        },
        onSubmit: this.onSubmitHandler(props),
        onFormChange: this.onFormChangeHandler(props),
        onFieldChange: this.onFieldChangeHandler(props),
        onValidateFailed: this.onValidateFailed(props),