react-codemirror
react-codemirror copied to clipboard
useCodeMirror: Updates to the onChange prop are ignored
I strongly recommend to revert 387a0c5b11991841cd40c880bc95cb389de87022 because it has introduced a bug.
It doesn't call the correct onChange, if props.onChange gets changed by the parent component.
But why?
onChange is never updated (current behaviour)
const handleChange = useCallback((value: string, vu: ViewUpdate) => onChange && onChange(value, vu), []);
The handler is updated when onChange updates (correct behaviour)
This has the same behaviour as just calling onCall directly – besides the check for it being falsy.
const handleChange = useCallback((value: string, vu: ViewUpdate) => onChange && onChange(value, vu), [onChange]);
@jaller94 thx!