Search code examples
reactjsreduxreact-reduxreact-localize-redux

How can I use translations in a component title?


I'm using react-translate-redux in a project for internationalization, but I don't know how to use translations in a component's properties. Specifically, I would like the title text of a component to be internationalized.

I would try the below,

<Button title={<Translate id="button">}>

but Type 'Element' is not assignable to type 'string'.

How can I internationalize the title text?


Solution

  • If you want to use Translate Component you can't pass it as a prop, you have to pass it as a child component and render it with this.props.children in your Button Render method.

    If Button Component is a external component you have to use prop function like in this in Flavour 2