React.JS - multiple elements sharing a state ( How do I modify only one of the elements without affecting the others? )
问题 class App extends Component { constructor(props) { super(props); this.state = { Card: Card } } HandleEvent = (props) => { this.SetState({Card: Card.Active} } render() { return ( <Card Card = { this.state.Card } HandleEvent={ this.handleEvent }/> <Card Card = { this.state.Card } HandleEvent={ this.handleEvent }/> ) } } const Card = props => { return ( <div style={props.state.Card} onClick={ props.HandleEvent}>Example</div> ) } Every time I click on one of the cards all of my elements change