Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
},
// 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]
}
},
// 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]
}
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]
}
},
...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]
}
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>
)
}