The Complete Guide to React Authentication with Auth0

Howdy, Avala. Thank you for joining the Auth0 Community and for your feedback :raised_hands:

If I understand correctly, the example that you’d like to see is as follows:

  • You have a component that makes API calls within a useEffect() hook.
  • The component stores the response from the API in a global Context component.
  • You limit access to the component by wrapping it up in a PrivateRoute Higher-Order Component.

Is that right? If so, I definitely have planned to provide an example of this in the close future.

Where it may get tricky is the following:

This useEffect hook calls a basic Axios.get function to populate a global context component which in turn populates our form fields.

This is more of an implementation detail of state management that could be done in different ways and could be the source of the performance error. For example, I default to Formik when I need to use forms in React. I have an app that has private routes to gate components with forms in them but I have not experienced an error like the one you pointed out yet, which makes me think the source of the error is not related to the presence of the PrivateRoute per se but something else :thinking:

2 Likes