How to keep or resupply React Context in a Gatsby site

后端 未结 3 1514
小鲜肉
小鲜肉 2021-01-02 18:06

I use React Context API to store the information that a user is authenticated.

In development mode when I type in any URL that redirects to the 404 error page the con

3条回答
  •  無奈伤痛
    2021-01-02 18:56

    I hope this helps you or others. The blog post below describes how you need to use gatsby-browser.js to wrap the root element in the provider so that it doesn't reset it on page change.

    https://www.gatsbyjs.org/blog/2019-01-31-using-react-context-api-with-gatsby/

提交回复
热议问题