children - ReactJS: how to access all child components in parent component? -
Suppose I have comments
with list component comments
components have got it. I want to apply the method that will return all the comments
components. I have been referred to each comment
component:
& Lt; Comments & gt; & Lt; Comment ref = "mycomments" text = "abc" /> & Lt; Comment ref = "mycomments" text = "efg" /> & Lt; / Comments & gt;
I thought that I can access all my components through this.refs.myComments
but this does not work - it only gives the final comment element < / P>
All the
comments
What's the way There is no right way to do this.
Your view is a representation of your data, so if you want text for all comments, see the data.
If you want to update comments, update the data.
Adding the data out of view, or manually adding the view manually, defeats the purpose of the reaction.
Comments
Post a Comment