Guide for UseContext

There’s basically 3 main things you need do to set up a shared state via useContext. Determine the top level component you want to pass your context to. For my “Smarter Way to Learn X” case, it was the App component, because any other route beneath it would consume that state. Create the context in its own file, and export it. This involves a simple 2 line code, in a ‘context’ folder of your app: ...

December 30, 2022 · 2 min · Lei