MAXListenerExceededWarning
Closed this issue · 4 comments
This repo should make it more clear that in order to avoid any warnings due to memory leaks from too many event emitter listeners, the user needs to add a context api around the whole app, which will only make it use one event emitter. I wasn't using the provider, only the dynamicvalue and dynamicstylesheet components, but I didn't know it was adding so many event emitters to my app.
Warning:
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 currentModeChanged listeners added. Use emitter.setMaxListeners() to increase limit
README.md
:
It is recommended to wrap your application in a
DarkModeProvider
without a mode prop to observe a performance improvement.
Some people don't need to wrap their apps and that's why I haven't mentioned it more explicitly.
@DimitarNestorov how do you use the context value in the child components' stylesheets then?
@chrise86 the context has a default value.
@DimitarNestorov wow that was a quick response, thanks! Got it, thanks!