I have a form with multiple text inputs. I have them all set up as controlled inputs. When typing, there is a lag of up to several seconds for the new text to display in the fie
My problem was that my state object was complex and thus causing rendering issues. My solution was to manage the state of the notes in my component, then on blur update the container state.
const { data, onEdit } = props;
const { containerNotes } = data;
const [notes, setNotes] = useState('');
useEffect(
() => {
setNotes(containerNotes);
},
[containerNotes],
);
const onChangeNotes = () => ({ target: { value } }) => {
setNotes(value);
};
const onBlurNotes = (prop) => ({ target: { value } }) => {
const newData = update(data, {
[prop]: { $set: value },
});
onEdit(newData);
};
return (
)