TarVK / model-react

A data model system to use with react hooks
https://tarvk.github.io/model-react/examples/build/
MIT License
13 stars 3 forks source link

does we need to clear removed listeners within in useDataHook #18

Closed tianyingchun closed 4 years ago

tianyingchun commented 4 years ago

while we make interaction in the view,

   const dependencyRemovers = useRef([] as (() => void)[]);

the more and more new removers will pushed into dependencyRemovers , even if we have removed.

TarVK commented 4 years ago

Oh very good point, thanks for bringing this to my attention, that's quite a bad memory leak! The code should indeed have contained a section to reset the removers after having called them.

I will try to release the fix for this over the weekend.

TarVK commented 4 years ago

For reference, this should also be clearing the removers after calling them: https://github.com/TarVK/model-react/blob/6977de0c45b80610e0e96cd402c82ce2ab1c3500/src/model/dataHooks/useDataHook.ts#L34