How to use the react-tinacms.useForm function in react-tinacms

To help you get started, we’ve selected a few react-tinacms 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 tinacms / tinacms / packages / gatsby-tinacms-json / src / use-json-form.ts View on Github external
// Parse the JSON into a JsonForm data structure and store it in state.
        const rawJson = JSON.parse(git.content)
        setValuesInGit({ jsonNode, rawJson })
      })
      .catch((e: any) => {
        console.log('FAILED', e)
      })
  }, [id])

  const fields = formOptions.fields || generateFields(valuesOnDisk.rawJson)

  // TODO: This may not be necessary.
  fields.push({ name: 'jsonNode', component: null })

  /* eslint-disable-next-line react-hooks/rules-of-hooks */
  const [, form] = useForm(
    {
      id,
      label,
      initialValues: valuesInGit,
      fields,
      onSubmit(data) {
        return cms.api.git.onSubmit!({
          files: [data.jsonNode.fileRelativePath],
          message: data.__commit_message || 'Tina commit',
          name: data.__commit_name,
          email: data.__commit_email,
        })
      },
      reset() {
        return cms.api.git.reset({ files: [id] })
      },

react-tinacms

> This package is no longer necessary or supported. You may instaed use the [`tinacms`](https://www.npmjs.com/tinacms) package directly.

Apache-2.0
Latest version published 4 years ago

Package Health Score

62 / 100
Full package analysis