i18next / i18next-gitbook

165 stars 172 forks source link

Add a note that not passing second arg to 'off' unsubscribes all listeners. #124

Closed bartlomiejzuber closed 4 years ago

bartlomiejzuber commented 4 years ago

Not sure if that's intended behavior but if it's I think it's worth to add this note.

I wasn't aware of this and this reflected in a hard to track bug. Long story short, when second argument passed to 'off' is undefined, all existing listeners will be removed. As listeners are tightly coupled to react-i18next, some of useTranslation hooks suddenly stopped triggering the update when internal react-i18next context changed.

wtf2

jamuhl commented 4 years ago

That's regular behaviour of an event emitter...anyway...merged as it does not hurt