How to consume same React context coming from different packages?
E.g. I have package A
which depends on common
and common
deps on ui-lib
, and packageA
deps on ui-lib
.
In ui-lib
there is an export const context = React.createContext({..})
and in package A
and in common
it will be different instances of the same context (because of different packages during the build).
I have few options now but they all.. not so good:
Solution A: re-export all the stuff from ui-lib
in common
, and in packageA
import only from common
Solution B: use two context Providers in package A
(one from ui-lib
and one from common
)
More context:
- I'm using npm without package locks
- I need this working while
package A
andcommon
builds separately on CI package A
andcommon
is inside monorepo andui-lib
is external package, so we have in our repo:
— packages
—— packageA (deps on `common` from same monorepo and `ui-lib` )
—— common (deps on `ui-lib`)
What could I do?