Hi, I was wondering about good patterns concerning the react context.
Let's get a public library, for example
react-intl that exposes a Provider (IntlProvider).
Let's create a library
barLib that uses
react-intl to manage translations internally and that also exposes a
Now let's imagine I create a web app and use both
I don't expect the
barLib to ever override my react-intl context, because i'm not aware it uses internally the
barLib can accidentally override the react-intl context => https://codesandbox.io/s/embedded-contexts-test-z8e7b
This kinda breaks the isolation of libs IMO.
I see several solutions :
- Don't use an other lib context in the
- Check that there is not already an intl context in the
barLib, if so merge the context values ?
I'm not convinced with either solutions, what do you guys think about it ?