I've always suspected that the Div-itis plaguing fb's website is a result of React's dependence on the 饾殬潭饾殶潭饾殠潭饾殯潭饾殲潭饾殰潭饾殠潭 misuse of higher order components.
I've always suspected that the Div-itis plaguing fb's website is a result of React's dependence on the 饾殬潭饾殶潭饾殠潭饾殯潭饾殲潭饾殰潭饾殠潭 misuse of higher order components.
HoCs don鈥檛 add nesting. If they do, you鈥檙e 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鈥檛 even need to return markup; they鈥檙e functions which return functions. The general expectation should be that an HoC behaves like a factory for the components it wraps.
Regardless of upgrade paths, React <15 would still let you use HoCs w/out adding excess element nesting.
I don鈥檛 contest that the older React tended towards div-itis if you weren鈥檛 careful with how you used it. But this thread was about Higher Order Components (or wrapper functions), which don鈥檛 have any inherent effect on nesting.
Also, HoCs have somewhat fallen out of favour over time, with hooks and the child as a function/render prop style becoming more popular. I think the only HoC I consistently use these days is `connect` from `react-redux`.
Edit: not sure they ever were actually, I think you could just return props.children in most cases?