Remove option warning in console

`option` throws an error in React if it’s not a string. `FormattedMessage` returns a `span` around strings, so any time this function was loaded/called, it was throwing >100 warnings in the console. use `intl` to return a string instead.
This commit is contained in:
Matthew Taylor 2016-08-12 15:47:44 -04:00
parent 6d5bb4f850
commit 0d9493de12

View file

@ -27,9 +27,14 @@ var Tooltip = require('../../components/tooltip/tooltip.jsx');
require('./steps.scss'); require('./steps.scss');
var DEFAULT_COUNTRY = 'us'; var DEFAULT_COUNTRY = 'us';
var getCountryOptions = function (defaultCountry) { var getCountryOptions = function (defaultCountry, intl) {
if (typeof intl === 'undefined') {
intl = defaultCountry;
defaultCountry = undefined;
}
var options = countryData.countryOptions.concat({ var options = countryData.countryOptions.concat({
label: <intl.FormattedMessage id="registration.selectCountry" />, label: intl.formatMessage({id: 'registration.selectCountry'}),
disabled: true, disabled: true,
selected: true selected: true
}); });
@ -347,7 +352,7 @@ module.exports = {
</div> </div>
<Select label={formatMessage({id: 'general.country'})} <Select label={formatMessage({id: 'general.country'})}
name="user.country" name="user.country"
options={getCountryOptions(DEFAULT_COUNTRY)} options={getCountryOptions(DEFAULT_COUNTRY, this.props.intl)}
required /> required />
<Checkbox className="demographics-checkbox-is-robot" <Checkbox className="demographics-checkbox-is-robot"
label="I'm a robot!" label="I'm a robot!"
@ -660,7 +665,7 @@ module.exports = {
<Form onValidSubmit={this.onValidSubmit}> <Form onValidSubmit={this.onValidSubmit}>
<Select label={formatMessage({id: 'general.country'})} <Select label={formatMessage({id: 'general.country'})}
name="address.country" name="address.country"
options={getCountryOptions()} options={getCountryOptions(this.props.intl)}
value={this.props.defaultCountry} value={this.props.defaultCountry}
onChange={this.onChangeCountry} onChange={this.onChangeCountry}
required /> required />