FormattedMessage is used in properties

when the framework uses antd and uses Input components, I need to display multiple languages in the placeholder property

the code is as follows:

<Search
    placeholder={<FormattedMessage id="S_T"/>}
    enterButton="Search"
    size="large"
    onSearch={value => console.log(value)}
    style={{height: "40px"}}
  />

when you use < FormattedMessage id= "slide" / > in the property, the page renders an object as shown in the following figure:

clipboard.png

Aug.30,2021

placeholder accepts strings, FormattedMessage this should be a component, if you want to achieve dynamic display of placeholder content, it is recommended to use a variable or function to achieve


you this is a component, directly write it, display no, multi-language is not a language pack, each language pack corresponding to an object data, with objects. Property method binding is fine.


Please refer to https://github.com/yahoo/reac., as follows

<FormattedMessage id="title">
    {(txt) => (
        <H1>
            {txt}
        </H1>
    )}
</FormattedMessage>
Menu