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

A Really Pesky Bug in React

I am going to document this bug because I believe it’s happened before, and it really took me quite a while the previous time to debug also. I’ll call this bug: can’t get past the first render. It involves inconsistencies in accessing props(i.e. data) from child components, causing the page to break. Yet, the description is really not helpful: TypeError: rowData is undefined react. The root cause of the bug lies in how React handles the logical flow of ReactHooks. For future me reading this, I’ll briefly detail the component structure: ...

August 25, 2021 · 3 min · Lei