re: You don't have to use Redux VIEW POST


Great post!

We additionally use a HoC to make using the Context API easier. Something like this:

const withUser = (Component) => (
  (props) => (
      {user => (

Then to use it ...

const UserBookList = (props) => (/* props.user */);

export default withUser()(UserBookList);

Would suggest to use useContext, either directly, or in the HOC:

const withUser = (Component) =>
  (props) => {
    const user = useContext(UserContext)
    return <Component {...props} user={user} />

Yep you sure could! The original example was without hooks, so I went that route.


You're welcome, hope it helps!

The Context.Consumer code scattered everywhere felt clunky.

code of conduct - report abuse