You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of the things that confused me when I was getting into React was the difference between props and state. I think passing down a prop called state could potentially trip up others as well...
in: what-is-react.md
Using props, again, we will pass the selected state from the component down to the component by placing the property state={this.state.selected} on all of the components. Now that we know the state (i.e., this.props.state) and the current value (i.e., this.props.value) of the option we can verify if the state matches the value. If it does, we then know that this option should be selected. This is done by writing a simple if statement which adds a styled selected state (i.e., selectedStyle) to the JSX
if the state matches the value of the current option. Otherwise, we return a React element with unSelectedStyle styles.
state={this.state.selected} could be a little clearer as selected={this.state.selected}
The text was updated successfully, but these errors were encountered:
One of the things that confused me when I was getting into React was the difference between
props
andstate
. I think passing down a prop called state could potentially trip up others as well...in: what-is-react.md
state={this.state.selected}
could be a little clearer asselected={this.state.selected}
The text was updated successfully, but these errors were encountered: