I know that I can pass props when rendering the component. I also know the getInitialState method. But the problem is that getInitialState does not help much, because my component does not know its initial state. I do. So I want to pass it on while I show it.
Something like this (pseudo code):
React.render(<Component initialState={...} />);
I know that I could use prop to work as the initial state, but it smells like an anti-pattern.
What should I do?
EDIT FOR CLARITY
Imagine I have a CommentList component. By the time I first created it, the initial state corresponds to a snapshot of the current comments from my database. Since the user includes comments, this list will change, and therefore it should be state , not props . Now, to display the original snapshot of the comments, I have to pass it to the CommentsList component, because it does not have the ability to know this. My confusion is that the only way I see this information is through props , which seems like an anti-pattern.
javascript reactjs
André Pena Jan 13 '15 at 17:47 2015-01-13 17:47
source share