This code works:
import { MessageResource } from 'react-intl'
.
.
.
<FlatButton label={`(${this.props.patCount})`}> {<MessageResource id="T_DUMMY_VALUE_KEY"/>} </FlatButton>
For ex: if <MessageResource id="T_DUMMY_VALUE_KEY"/>
gives string Patients
and ${this.props.patCount}
gives 10 then the label will turn out to be:
Patients (10)
But my requirement is to bring all the string processing together within label attribute something like this:
import { MessageResource } from 'react-intl'
.
.
.
<FlatButton label={<MessageResource id="T_DUMMY_VALUE_KEY"/> + `(${this.props.patCount})`} />
This does not work and gives me output like this:
[OBJECT OBJECT] (10)
Please help.
Check this link for more information.
Lets say you have one message that has an id: message_one_id And you want to concatenate the second message into it.
Your Messages json file looks like below if you have one. Or I am doing the below example with defaultMessages.
You can use the following method:
This will output:
Unread (Loading...)
You can also use this to even dynamically print message:
This will output:
Unread (2)