React-Intl How to use FormattedMessage in input placeholder

前端 未结 11 661
走了就别回头了
走了就别回头了 2020-12-13 03:20

I\'m unsure how to get the values from


into a placeholder format like input:<

11条回答
  •  余生分开走
    2020-12-13 04:16

    In my case I had the whole app in one file, so using export wouldn't work. This one uses the normal class structure so you can use the state and other functionality of React if needed.

    class nameInputOrig extends React.Component {
      render () {
        const {formatMessage} = this.props.intl;
        return (
            
        );
      }
    }
    
    const nameInput = injectIntl(nameInputOrig);
    

    Apply using the created constant:

    class App extends React.Component {
        render () {
            
        }
    }
    

提交回复
热议问题