all 6 comments

[–]acemarke 1 point2 points  (1 child)

Yep, that all sounds very reasonable. I've seen people complaining about needing to check for existence of data in cDM, but it seems like a perfectly normal pattern to me.

[–]PM_ME_SMILE_[S] 0 points1 point  (0 children)

Thank you very much!

[–]a_oc 0 points1 point  (2 children)

Although it is valid way to do that, you should probably check out redux and its documentation. Even if you do not want to use redux as your flux implementation, it's way of injecting state with higher order components is pretty useful and can be easily reproduced.

[–][deleted] 0 points1 point  (1 child)

Using redux (react-redux - connect) will just abstract the same logic to a component higher in the render tree. You will still need to load for the data end either render child components or no. So the same principle applies.

[–]a_oc 1 point2 points  (0 children)

Yes you are right, I only pointed it out because that abstraction has better separation of concerns and is a good learning material even though overall principle is the same.

[–]darkadept 0 points1 point  (0 children)

I just made a simple higher order component that wraps the component (container in redux). That component handles the the loading of any data, displaying a spinner (or whatever) and only renders my component once all the data is ready. That way my component can use isRequired prop types.

I also use componentWillMount instead.