React Context API not working from custom NPM component library

后端 未结 3 880
清酒与你
清酒与你 2021-02-19 20:24

I\'ve built a ReactJS component library that I use for multiple projects installed via an NPM package using a sim link. I want to use the context API to pass data from a parent

3条回答
  •  無奈伤痛
    2021-02-19 20:53

    Apart from Darko's answer, esm and cjs export is also a possible reason for context to fail in a package. If you use the hook in esm and the provider in cjs, you will not get the value for that context.

提交回复
热议问题