1

I use higher order components (HOC) all the time in React, but I'm a little confused as to the theory behind them.

Why do I need to include a prop in an HOC to make it available in child components?

Why can't there be a pattern to import a hook within a function component to access a global variable that's not wrapped? Why MUST an HOC wrap the app for it to be available?

For instance, the Redux useSelector hook requires my store be wrapped in my app. But why? What is going on in React that requires this wrapping?

Zoe
  • 27,060
  • 21
  • 118
  • 148
Gary
  • 909
  • 9
  • 26

0 Answers0