In situations where you initialize useState
with some value and later on you want to update the state,
because the parent changed, you would need to currently listen on the parent change in an useeffect
and then set the state to update it, or more precisely, update the local version.
For this a hook I use quite often for forms or temporarily updated values is the useLocal
hook.
const RangeDatepicker = ({ value: { from, to }, onChange }) => {