How to use the react-tinacms.useLocalForm 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 / next-tinacms-markdown / src / index.ts View on Github external
export function useMarkdownForm(
  markdownRemark: Markdown,
  formOverrrides: FormOptions
) {
  const cms = useCMS()

  // let throttledOnChange = React.useMemo(() => {
  // return throttle(cms.api.git.onChange, 300)
  // }, [])
  const [values, form] = useLocalForm({
    label: markdownRemark.path,
    id: markdownRemark.path,
    initialValues: markdownRemark,
    async onSubmit(data) {
      console.log({ data })
      await cms.api.git.onChange!({
        fileRelativePath: data.path,
        content: toMarkdownString(data),
      })
      return await cms.api.git.onSubmit!({
        files: [data.path],
        message: data.__commit_message || 'commit from tina',
        name: data.__commit_name,
        email: data.__commit_email || 'ncphillips.19@gmail.com',
      })
    },

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