For eample:
<Counter start="10">
...
export default class Counter extends React.Component {
constructor(props) {
super();
this.state = {
start: props.start
};
}
}
I googled this question and I got an idea that the answers I found are outdated
The questions on StackOVerflow
- ReactJS: Why is passing the component initial state a prop an anti-pattern?
- ReactJs: How to pass the initial state while rendering a component?
But I found this post in React blog: React v0.13.0 Beta 1
And in that post author does exactly what I want, as I understand getDefaultProps
is deprecated now.
So the question is: Is passing state through props still an anti-pattern?