Skip to content

Commit 0e6b3e3

Browse files
committed
Replace Object.assign with object spread property syntax
1 parent 074c9b5 commit 0e6b3e3

File tree

11 files changed

+43
-26
lines changed

11 files changed

+43
-26
lines changed

examples/translations/src/client/components/locales-menu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {Component, PropTypes} from 'react';
1+
import React, {Component} from 'react';
22
import {intlShape, defineMessage} from 'react-intl';
33

44
const enUSDescription = defineMessage({

scripts/build-locale-data.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default ${serialize(localeData)};
2828
);
2929
}
3030

31-
function createDataDistFile(localeData) {
31+
function createDistDataScript(localeData) {
3232
return (
3333
`// GENERATED FILE
3434
ReactIntl.addLocaleData(${serialize(localeData)});
@@ -51,5 +51,5 @@ fs.writeFileSync('src/locale-data/index.js',
5151

5252
dataByLang.forEach((data, lang) => {
5353
fs.writeFileSync(`src/locale-data/${lang}.js`, createDataModule(data));
54-
fs.writeFileSync(`dist/locale-data/${lang}.js`, createDataDistFile(data));
54+
fs.writeFileSync(`dist/locale-data/${lang}.js`, createDistDataScript(data));
5555
});

src/components/date.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ export default class FormattedDate extends Component {
2121
}
2222
}
2323

24-
FormattedDate.propTypes = Object.assign({}, dateTimeFormatPropTypes, {
24+
FormattedDate.propTypes = {
25+
...dateTimeFormatPropTypes,
2526
format: PropTypes.string,
2627
value : PropTypes.any.isRequired,
27-
});
28+
};
2829

2930
FormattedDate.contextTypes = {
3031
intl: intlShape.isRequired,

src/components/html-message.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ export default class FormattedHTMLMessage extends Component {
1111
return true;
1212
}
1313

14-
return shouldIntlComponentUpdate(this,
15-
Object.assign({}, nextProps, {values: null}),
16-
...next
17-
);
14+
let nextPropsToCheck = {
15+
...nextProps,
16+
values: null,
17+
};
18+
19+
return shouldIntlComponentUpdate(this, nextPropsToCheck, ...next);
1820
}
1921

2022
render() {

src/components/intl.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ export default class IntlProvider extends Component {
4747
// Bind intl factories and current config to the format functions.
4848
let boundFormatFns = this.getBoundFormatFns(intl, config);
4949

50-
return {intl: Object.assign({}, config, boundFormatFns)};
50+
return {
51+
intl: {
52+
...config,
53+
...boundFormatFns,
54+
},
55+
};
5156
}
5257

5358
shouldComponentUpdate(...next) {
@@ -59,9 +64,9 @@ export default class IntlProvider extends Component {
5964

6065
if (typeof children === 'function') {
6166
// TODO: Pass the result of `this.getChildContext()` to the child fn?
62-
// Or just `Object.assign({}, this.props, this.state)`? Or nothing!?
63-
// Passing stuff would expose the underlying info and make it part
64-
// of the public API.
67+
// Or just `{...this.props, ...this.state}`? Or nothing!? Passing
68+
// stuff would expose the underlying info and make it part of the
69+
// public API.
6570
return children();
6671
}
6772

src/components/message.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ export default class FormattedMessage extends Component {
1111
return true;
1212
}
1313

14-
return shouldIntlComponentUpdate(this,
15-
Object.assign({}, nextProps, {values: null}),
16-
...next
17-
);
14+
let nextPropsToCheck = {
15+
...nextProps,
16+
values: null,
17+
};
18+
19+
return shouldIntlComponentUpdate(this, nextPropsToCheck, ...next);
1820
}
1921

2022
render() {

src/components/number.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ export default class FormattedNumber extends Component {
2121
}
2222
}
2323

24-
FormattedNumber.propTypes = Object.assign({}, numberFormatPropTypes, {
24+
FormattedNumber.propTypes = {
25+
...numberFormatPropTypes,
2526
format: PropTypes.string,
2627
value : PropTypes.any.isRequired,
27-
});
28+
};
2829

2930
FormattedNumber.contextTypes = {
3031
intl: intlShape.isRequired,

src/components/plural.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ export default class FormattedPlural extends Component {
2222
}
2323
}
2424

25-
FormattedPlural.propTypes = Object.assign({}, pluralFormatPropTypes, {
25+
FormattedPlural.propTypes = {
26+
...pluralFormatPropTypes,
2627
value: PropTypes.any.isRequired,
2728
other: PropTypes.node.isRequired,
2829
zero : PropTypes.node,
2930
one : PropTypes.node,
3031
two : PropTypes.node,
3132
few : PropTypes.node,
3233
many : PropTypes.node,
33-
});
34+
};
3435

3536
FormattedPlural.defaultProps = {
3637
style: 'cardinal',

src/components/relative.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ export default class FormattedRelative extends Component {
2121
}
2222
}
2323

24-
FormattedRelative.propTypes = Object.assign({}, relativeFormatPropTypes, {
24+
FormattedRelative.propTypes = {
25+
...relativeFormatPropTypes,
2526
format: PropTypes.string,
2627
value : PropTypes.any.isRequired,
2728
now : PropTypes.any,
28-
});
29+
};
2930

3031
FormattedRelative.contextTypes = {
3132
intl: intlShape.isRequired,

src/components/time.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ export default class FormattedTime extends Component {
2121
}
2222
}
2323

24-
FormattedTime.propTypes = Object.assign({}, dateTimeFormatPropTypes, {
24+
FormattedTime.propTypes = {
25+
...dateTimeFormatPropTypes,
2526
format: PropTypes.string,
2627
value : PropTypes.any.isRequired,
27-
});
28+
};
2829

2930
FormattedTime.contextTypes = {
3031
intl: intlShape.isRequired,

0 commit comments

Comments
 (0)