I may be misunderstanding how react context work in general, but how I think it should work goes like this:
I have a main app that has the Context provider as following
export default function app(){
return <contextObj.Provider value={Complex Object with multiple properties...}>
<Main/>
</contextObj.Provider>
}
My main app is as follows
export default function main(){
//Have imported the context class and am using it
let store = React.useContext(myContext)
return <React.Fragment>
<comp1 max={store.valueX} />
<comp2 />
</React.Fragment>
}
Inside of comp2, modify valueX inside of the context objext
export default function comp2(){
//Have imported the context class and am using it
let store = React.useContext(myContext)
return <buttonComp onClick={()=>store.valueX=3} />
}
So in theory comp1 should receive the updated value and re-render? This is where I'm stuck, as altering the context property isn't causing my comp1 to re-render.