简体   繁体   English

将 react-intl 与 react-table 集成

[英]Integrate react-intl with react-table

I am using react-intl for translations throughout my app.我在整个应用程序中使用react-intl进行翻译。 I am now trying to use a translated message as Header of a table using react-table in the following way:我现在正在尝试通过以下方式使用react-table将翻译后的消息用作表的 Header:

    {
    Header: <FormattedMessage id="users.user" defaultMessage="User" />,
    accessor: 'role',
},

But I get the following errror message:但我收到以下错误消息:

×

Error: A column ID (or string accessor) is required!错误:需要列 ID(或字符串访问器)!

You can try using intl.formatMessage API instead.您可以尝试改用intl.formatMessage API。

Just Add id element to the object like this:只需像这样将 id 元素添加到 object 中:

{
 Header: <FormattedMessage id="users.user" defaultMessage="User" />,
 id:'h1', //<--------------
accessor: 'role',
},

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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