albertogasparin / react-magnetic-di

Dependency injection and replacement for Javascript and React components/hooks
MIT License
131 stars 7 forks source link

DiProvider with global does not clean replacementMap on error #88

Closed albertogasparin closed 9 months ago

albertogasparin commented 10 months ago

Whenever <DiProvider global /> is used and the tree throws an error, we skip the unmount use effect and replacements between tests are not cleared.

We should convert DiProvider to a class and add componentDidCatch to call globalDi.clear()

theKashey commented 10 months ago

This is one way to solve the problem, another way is to enforce cleanup between tests:

albertogasparin commented 10 months ago

Yes, might eventually go down that path. For now my worry was with tests and storybooks blowing up and then leaks would happen

theKashey commented 9 months ago

:fingerguns: we definitely missing this sort of cleanup for storybook and tests