Closed TarVK closed 3 years ago
I've noticed React complaining about invalid hook calls, and just realized the cause of this. I'm not properly cleaning up timeout on unmount: https://github.com/TarVK/model-react/blob/05a1efaafe1ac1153f99ae79cd084e7f434d559a/src/model/dataHooks/useDataHook.ts#L61
Simply adding a useEffect hook that clears the current timeout on unmount should fix this issue. It's worth considering whether we still want to trigger the onChange callback in that situation or not.
onChange
I've noticed React complaining about invalid hook calls, and just realized the cause of this. I'm not properly cleaning up timeout on unmount: https://github.com/TarVK/model-react/blob/05a1efaafe1ac1153f99ae79cd084e7f434d559a/src/model/dataHooks/useDataHook.ts#L61
Simply adding a useEffect hook that clears the current timeout on unmount should fix this issue. It's worth considering whether we still want to trigger the
onChange
callback in that situation or not.