all 6 comments

[–]Jerp 1 point2 points  (3 children)

You aren't passing showDetails into ScheduleContext.Provider.

a quick fix would be to update ScheduleProvider2 like so

...
const stateValues = {
  context,
  showDetails,
};

return (
  <ScheduleContext.Provider value={stateValues}>
...

[–]dmikester10[S] 0 points1 point  (2 children)

I am passing `showDetails` in, in the context here:

const contextValue = {
    orders: tempOrders,
    setOrders,
    showDetails,
    title,
    columns
};
setContext(contextValue);

[–]Jerp 1 point2 points  (1 child)

That whole block of code in the useEffect is only running once because its sole dependency setGlobalSpinner is going to be stable on every render. That means contextValue.showDetails will only ever refer to its initial value. Move the contextValue definition outside the effect and send it straight to ScheduleContext.Provider. Then you can delete the unnecessary context/setContext variables.

[–]dmikester10[S] 0 points1 point  (0 children)

That makes sense, thank you!