Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit 94d327a

Browse files
committed
Merge branch 'tw0517tw-shallow-compare'
2 parents b5ebfbc + e230420 commit 94d327a

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
"dependencies": {
7373
"flat": "^2.0.0",
7474
"icepick": "^1.1.0",
75-
"lodash": "^4.10.0"
75+
"lodash": "^4.10.0",
76+
"react-addons-shallow-compare": "^15.0.2"
7677
},
7778
"peerDependencies": {
7879
"react": "^0.14.0 || ^15.0.0",

src/components/field-component.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { Component, PropTypes } from 'react';
2+
import shallowCompare from 'react-addons-shallow-compare';
23
import connect from 'react-redux/lib/components/connect';
34

45
import _get from 'lodash/get';
@@ -161,6 +162,10 @@ function createFieldClass(customControlPropsMap = {}, defaultProps = {}) {
161162
};
162163

163164
class Field extends Component {
165+
shouldComponentUpdate(nextProps, nextState) {
166+
return shallowCompare(this, nextProps, nextState);
167+
}
168+
164169
render() {
165170
const { props } = this;
166171
const component = getFieldWrapper(props);

test/form-component-spec.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,10 @@ describe('<Form> component', () => {
625625
errors={{
626626
bar: (val) => val !== 'bar' && 'bar invalid',
627627
}}
628-
onSubmit={(val) => (submitValue = val, true)}
628+
onSubmit={(val) => {
629+
submitValue = val;
630+
return true;
631+
}}
629632
>
630633
<Field model="test.foo">
631634
<input type="text" />

0 commit comments

Comments
 (0)