Does useContext work for components coming from other projects?

130 Views Asked by At

lets say I have two different project(repo), named P1 and P2, P2 is a dependency for P1.

inside one of the component(C1) in P1, I am importing a component(C2) from P2. now I need to pass bunch of callbacks to C2 from C1 and I want to use React context.

the problem here is I do not have access to the argument I am suppose to pass to useContext. is this because child component is from different project?

const context = React.createContext(contextData)

const C1 = ({props}) => {
return <Context.Provider value={} >
          <C2 {...someProps} />
        </Context.Provider>

}

const C2 = ({props}) => {
const context = useContext(context) // there is no access to context here 
return <div></div>
}
0

There are 0 best solutions below