React useContext: How to Update Context from Child Component

Why useContext

  • an alternative to using Redux
  • allows you to avoid “props-drilling”, which means that if you have a deep nesting of your components, you won’t have to pass the props all that way down

Context is well explained in the official React documentation, so I decided to go with rather a practical example.