DEV Community

Discussion on: Higher Order Components and Context Example

Collapse
 
koverg70 profile image
Gábor Kövér

Hi, Just finished reading your articles about HOCs and I enjoyed it very much, thank you.

One small notice though: in this example you put both the items array and the getItems function into the context. It works well when you have only one ConnectedList rendered on your page, but if you have more than one with different src it will not.

I suggest that you only put getItems (the service itself and not the ruslts) in the context. This way you can store the result in your HOC (ItemComponent), and can provide it to your List as well.

Keep up the good work!

Collapse
 
kayis profile image
K

Hey,

yes, I know that this wouldn't work for multiple lists, but I wanted to keep the example simple.

I would given every list a key in the context, to store them right, but your example seems to be better, thanks for the tip :)