Thanks for the article Cassidy. How would you go about updating the context values? I have an API request that will be fired, and on response, I'd like to update the context.
You can do that in any state variables you store in the Context! In your example, I'd probably call your API in a useEffect and then set a state variable in that, and then make sure that state variable is passed into Context. Here's an example of that from the Jamstack Explorers GitHub repo: github.com/netlify/explorers/blob/...
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the article Cassidy. How would you go about updating the context values? I have an API request that will be fired, and on response, I'd like to update the context.
You can do that in any state variables you store in the Context! In your example, I'd probably call your API in a
useEffect
and then set a state variable in that, and then make sure that state variable is passed into Context. Here's an example of that from the Jamstack Explorers GitHub repo: github.com/netlify/explorers/blob/...