Ask questionsBug: React Context API is not working from custom NPM library
I have total of three npm packages:
If I have these components in a single app, everything works as expected. However, if I separate them to their own npm packages, the state is no longer retrievable by the consumer.
React version: 16.13.1
Link to code example: https://github.com/ayayalar/ReactContextAPIDefect
<!-- Please provide a CodeSandbox (https://codesandbox.io/s/new), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. You may provide a screenshot of the application if you think it is relevant to your bug report. Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve. -->
The context state is not retrievable by the consumer.
The context state should be retrievable by the consumer.
Answer questions vkurchatkin
React works the same regardless of whether you have a single file or not, whether you use a bundler or not. If you have a problem with context you need to ensure that provider and consumer really use the same Context object. It is most likely that they are not