mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-26 18:58:17 +00:00
committed by
Brandon Dail
parent
6ab71526ee
commit
3aa1d52f96
@@ -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