@nozify/form-builder
TypeScript icon, indicating that this package has built-in type declarations

0.3.51 • Public • Published

React-native form-builder

Getting Started

npm --save @rjsf/core @nozify/form-builder
# This package also depends on `@react-native-community/slider`
npm --save @react-native-community/slider

Usage

import FormBuilder, { defaultProps, FormContext } from '@nozify/form-builder';

const schema = {
  title: 'Todo',
  type: 'object',
  required: ['title'],
  properties: {
    title: { type: 'string', title: 'Title', default: 'A new task' },
    done: { type: 'boolean', title: 'Done?', default: false },
  },
};

const Form = () => {
  const form: any = useRef<any>();

  const onSubmit = (formData: any) => {};

  return (
    <FormContext.Provider
      value={{
        ...defaultProps,
      }}>
      <ScrollView>
        {schema && (
          <FormBuilder
            ref={form}
            onError={(e) => {
              console.log(e);
            }}
            schema={schema as any}
            onSubmit={(f: any) => onSubmit(f.formData)}>
            <Button
              title="Save"
              onPress={() => {
                if (form.current) {
                  (form.current as any)?.submit();
                }
              }}
            />
          </FormBuilder>
        )}
      </ScrollView>
    </FormContext.Provider>
  );
};

Readme

Keywords

none

Package Sidebar

Install

npm i @nozify/form-builder

Weekly Downloads

0

Version

0.3.51

License

none

Unpacked Size

15 kB

Total Files

28

Last publish

Collaborators

  • turtuvshin