<Form
mutators={{
// expect (field, value) args from the mutator
setValue: ([field, value], state, { changeValue }) => {
changeValue(state, field, () => value)
}
}}
render={({ form, ...rest }) => {
// put the reference on a window variable of your choice here
if (!window.setFormValue) window.setFormValue = form.mutators.setValue
return (
<>
<Field name="field1">...</Field>
<Field name="field2">...</Field>
...
</>
)
}}
/>
// somewhere else, outside of the React application
window.setFormValue('field1', 'value1')
window.setFormValue('field2', 'value2')