import { Form, useFieldReader, useFieldTrigger } from "@idler8/form-react";
const Input = ({ value = "", onChange }) => (
<input value={value} onChange={(e) => onChange?.(e.target.value)} />
);
const Field = ({ name }) => {
const value = useFieldReader(name);
const onChange = useFieldTrigger(name);
return <Input value={value} onChange={onChange} />;
};
const Fields = () => {
const value = useFieldReader();
const onChange = useFieldTrigger();
useEffect(() => {
onChange({ formKey: { fieldKey: 2 } });
}, []);
return (
<div>
<div>{JSON.stringify(value)}</div>
<Field name={["formKey", "fieldKey"]} />
</div>
);
};
ReactDOM.createRoot(document.getElelemtByID("root")).render(
<Form>
<Fields />
</Form>
);
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.