简体   繁体   中英

add React-intl to placeholder IN OBJECT

I have a problem with const inputProps . I try add a React-intl to react-autosuggest placeholder input, but now, this placeholder is: [Object object] .

getStepContent = (step) => {    
    const inputProps = {
      placeholder: <FormattedMessage {...messages.inputAccountNumber} />, // <--
      value,
      onChange: this.onChange,
      maxLength: 26,
    };

...

    switch (step) {
      case 0:
        return (
          <Fragment>
            <Autosuggest
              inputProps={inputProps} // <--
            />
          </Fragment>
        );
...

Placeholder is a string, you putted an Object in it. You can write the code like this:

import intl from 'react-intl-universal'
...
placeholder: intl.get(messages.inputAccountNumber).d(messages.inputAccountNumber), // <--

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM