0

I am having a Question About React Context API

For Instance, I have the following App structure:

<AppContext>
   <LoadingScreen/>
   <SignUpFormPage/>
   <ProfileFormPage/>
   <ApplyFormPage/>
</AppContext>

Now I would like to have a state call isLoading in <AppContext>, I will change it to true whenever a user submit form on <SignUpFormPage/>, <ProfileFormPage/>, or <ApplyFormPage/> , Is there an implementation that all pages can change the isLoading state in the context, but only LoadingScreen will be re-rendered?

  • Its not possible, all Context consumers will *always rerender* (v18). There is no bailout for Context API, for your use case you looking to subscribe to a "part" of a state, which too is not part of the API, use any state management instead. – Dennis Vash Apr 13 '22 at 06:41

0 Answers0