How to use the react-tinacms.useWatchFormValues 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 / index.ts View on Github external
},
    // The Form will be updated if these values change.
    { values: valuesOnDisk, label, fields }
  )

  /* eslint-disable-next-line react-hooks/rules-of-hooks */
  const writeToDisk = useCallback(formState => {
    const { fileRelativePath, rawJson, ...data } = formState.values.rawJson
    cms.api.git.onChange!({
      fileRelativePath: formState.values.jsonNode.fileRelativePath,
      content: JSON.stringify(data, null, 2),
    })
  }, [])

  /* eslint-disable-next-line react-hooks/rules-of-hooks */
  useWatchFormValues(form, writeToDisk)

  return [jsonNode, form as Form]
}
github tinacms / tinacms / packages / gatsby-tinacms-json / src / use-json-form.ts View on Github external
},
    // The Form will be updated if these values change.
    { values: valuesOnDisk, label, fields }
  )

  /* eslint-disable-next-line react-hooks/rules-of-hooks */
  const writeToDisk = useCallback(formState => {
    const { rawJson, jsonNode } = formState.values
    cms.api.git.onChange!({
      fileRelativePath: jsonNode.fileRelativePath,
      content: JSON.stringify(rawJson, null, 2),
    })
  }, [])

  /* eslint-disable-next-line react-hooks/rules-of-hooks */
  useWatchFormValues(form, writeToDisk)

  return [jsonNode, form as Form]
}
github tinacms / tinacms / packages / gatsby-tinacms-remark / src / useRemarkForm.tsx View on Github external
label,
      fields,
      values: valuesOnDisk,
    }
  )

  /* eslint-disable-next-line react-hooks/rules-of-hooks */
  const writeToDisk = React.useCallback(formState => {
    cms.api.git.onChange!({
      fileRelativePath: formState.values.fileRelativePath,
      content: toMarkdownString(formState.values),
    })
  }, [])

  /* eslint-disable-next-line react-hooks/rules-of-hooks */
  useWatchFormValues(form, writeToDisk)

  return [markdownRemark, form]
}
github tinacms / tinacms / packages / gatsby-tinacms-json / index.ts View on Github external
},
      ...formOptions,
    },
    // The Form will be updated if these values change.
    { values: valuesOnDisk, label, fields }
  )

  const writeToDisk = useCallback(formState => {
    const { fileRelativePath, rawJson, ...data } = formState.values.rawJson
    cms.api.git.onChange!({
      fileRelativePath: formState.values.jsonNode.fileRelativePath,
      content: JSON.stringify(data, null, 2),
    })
  }, [])

  useWatchFormValues(form, writeToDisk)

  return [jsonNode, form as Form]
}
github tinacms / tinacms / packages / demo-next / pages / [slug].js View on Github external
fields: [
      {
        name: "title",
        component: "text"
      }
    ],
  })

  let writeToDisk = React.useCallback(formState => {
    cms.api.git.writeToDisk({
      fileRelativePath: props.fileRelativePath,
      content: JSON.stringify({title: formState.values.title})
    })
  }, [])

  useWatchFormValues(form, writeToDisk)

  return (
    <>
      <h1>{post.title}</h1>
    
  )
}

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