Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

Commit

Permalink
Remove useless optimisation (#736)
Browse files Browse the repository at this point in the history
  • Loading branch information
istarkov committed Aug 30, 2018
1 parent b70602b commit 2b1741f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
18 changes: 9 additions & 9 deletions .size-snapshot.json
@@ -1,18 +1,18 @@
{
"lib/packages/recompose/dist/Recompose.umd.js": {
"bundled": 46995,
"minified": 16584,
"gzipped": 4651
"bundled": 46555,
"minified": 16485,
"gzipped": 4623
},
"lib/packages/recompose/dist/Recompose.min.js": {
"bundled": 43433,
"minified": 15304,
"gzipped": 4220
"bundled": 42993,
"minified": 15205,
"gzipped": 4193
},
"lib/packages/recompose/dist/Recompose.esm.js": {
"bundled": 31320,
"minified": 14839,
"gzipped": 3451,
"bundled": 30894,
"minified": 14729,
"gzipped": 3417,
"treeshaked": {
"rollup": {
"code": 340,
Expand Down
9 changes: 0 additions & 9 deletions src/packages/recompose/withStateHandlers.js
@@ -1,7 +1,6 @@
import { createFactory, Component } from 'react'
import setDisplayName from './setDisplayName'
import wrapDisplayName from './wrapDisplayName'
import shallowEqual from './shallowEqual'
import mapValues from './utils/mapValues'

const withStateHandlers = (initialState, stateUpdaters) => BaseComponent => {
Expand All @@ -27,14 +26,6 @@ const withStateHandlers = (initialState, stateUpdaters) => BaseComponent => {
}
)

shouldComponentUpdate(nextProps, nextState) {
const propsChanged = nextProps !== this.props
// the idea is to skip render if stateUpdater handler return undefined
// this allows to create no state update handlers with access to state and props
const stateChanged = !shallowEqual(nextState, this.state)
return propsChanged || stateChanged
}

render() {
return factory({
...this.props,
Expand Down

0 comments on commit 2b1741f

Please sign in to comment.