4 ms·
It’s not. HoCs don’t add nesting. If they do, you’re doing it wrong. React <15 (2yrs old), did nudge you in the direction of div-itis, because all components
by the_other 6y ago
It’s not.
HoCs don’t add nesting. If they do, you’re doing it wrong.
React <15 (2yrs old), did nudge you in the direction of div-itis, because all components that rendered something had to render a single root element. The more recent versions did away with that constraint. HoCs don’t even need to return markup; they’re functions which return functions. The general expectation should be that an HoC behaves like a factory for the components it wraps.
- 5cott0 6y agoSo every React app can be effortlessly refactored to use whatever shiny new latest and greatest architecture abstraction React comes up with?
- the_other 6y agoNo, and FB themselves discourage this in their documentation. Regardless of upgrade paths, React <15 would still let you use HoCs w/out adding excess element nesting. I don’t contest that the older React tended towards div-itis if you weren’t careful with how you used it. But this thread was about Higher Order Components (or wrapper functions), which don’t have any inherent effect on nesting.