1.0.3 • Published 1 year ago

react-inertia-form v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

InertiaForm Component

InertiaForm component that is similar to formik but uses the useForm hook by inertia underneath

Parent dependencies

  • react
  • @inertiajs/react

How To Use

import { InertiaForm, LabelField, Form } from './InertiaForm';

function App() {

  return (
    <div className="App">
      <InertiaForm
      onSubmit={(data) => console.log(data)}
      enableReInitialization={true}
      initialValues={{name: '', last_name: ''}}
      >
        {({data, setData, errors, reset, progress,processing,  handleSubmit})=> (
          <>
          <Form>
            <LabelField label='Name' name='name'/>
            <LabelField label='Last Name' name='last_name' />
          </Form>
          <button onClick={handleSubmit}>Submit</button>
          </>
        )}
      </InertiaForm>
    </div>
  );

}

export default App;

InertiaForm

InertiaForm component sets the context using useForm hook and initial values.

props

namedata typerequired
initialValuesobjecttrue
onSubmitfunctiontrue
enableReInitializationbooleanfalse

Form

renders form and passes the submit function

LabeledDropdown

Renders a labled dropdown

props

namedata typerequired
listarraytrue
namestringtrue
labelstringfalse
errorClassNamestringfalse
labelClassNamestringfalse
selectClassNamestringfalse
onChangefunctionfalse

LabelField

props

namedata typerequired
disabledbooleanfalse
namestringtrue
labelstringfalse
typestringfalse
placeholderstringfalse
errorClassNamestringfalse
labelClassNamestringfalse
fieldClassNamestringfalse
onChangefunctionfalse

LabelTextArea

props

namedata typerequired
rowsintegerfalse
colsintegerfalse
namestringtrue
labelstringfalse
placeholderstringfalse
errorClassNamestringfalse
labelClassNamestringfalse
textareaClassNamestringfalse
onChangefunctionfalse
1.0.2

1 year ago

1.0.3

1 year ago

1.0.0

1 year ago