mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
committed by
Brandon Dail
parent
71fb1e6dcb
commit
284b028b43
@@ -184,7 +184,7 @@ class WordAdder extends React.Component {
|
||||
}
|
||||
```
|
||||
|
||||
The problem is that `PureComponent` will do a simple comparison between the old and new values of `this.props.words`. Since this code mutates the `words` array in the `handleClick` method of `WordAdder`, the old and new values of `this.props.words` will compare as equal, even though the actual words in the array have changed. The `ListOfWords` will thus not update even though it has new words that shoud be rendered.
|
||||
The problem is that `PureComponent` will do a simple comparison between the old and new values of `this.props.words`. Since this code mutates the `words` array in the `handleClick` method of `WordAdder`, the old and new values of `this.props.words` will compare as equal, even though the actual words in the array have changed. The `ListOfWords` will thus not update even though it has new words that should be rendered.
|
||||
|
||||
## The Power Of Not Mutating Data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user