React Context API not working from custom NPM component library

后端 未结 3 929
清酒与你
清酒与你 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:45

    should your code of consumer be

          
            
              {value => /* render something based on the context value */}
            
          
    

    as stated from the official react doc : https://zh-hant.reactjs.org/docs/context.html

    when you define

    you can use it like

提交回复
热议问题