Skip to content

Commit 782dc7b

Browse files
authored
Update 01.shouldComponentUpdate-check.md
that if statement can be returned to a flat return
1 parent 252ea07 commit 782dc7b

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

perf-tips/01.shouldComponentUpdate-check.md

+2-7
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,8 @@ const AutocompleteItem = (props) => {
3737
```javascript
3838
export default class AutocompleteItem extends React.Component {
3939
shouldComponentUpdate(nextProps, nextState) {
40-
if (
41-
nextProps.url !== this.props.url ||
42-
nextProps.selected !== this.props.selected
43-
) {
44-
return true;
45-
}
46-
return false;
40+
return nextProps.url !== this.props.url ||
41+
nextProps.selected !== this.props.selected;
4742
}
4843

4944
render() {

0 commit comments

Comments
 (0)