Warning: Missing translation for key: "";
Asked Answered
R

3

9

I am using react-admin for creating my website. But i am getting this warning from list page every time 'Warning: Missing translation for key: "";'

const ListTitle = () => {
    return <span>User Agents</span>;
}

 const SitemapFilter = props => (
    <Filter {...props}>
     <TextInput label="Type" source="type" alwaysOn/>
   </Filter>
   );

  export const SitemapList = props => (
     <List {...props} filters={<SitemapFilter />} title={<ListTitle />}>
    <Datagrid>
     <TextField source="type" label="Type"/>
     <UrlField source="url" label="URL"/>
     <EditButton/>
   </Datagrid>
 </List>
);

I am not able to find the reason. Please advise. Thanks in advance.

Romeo answered 15/2, 2019 at 11:6 Comment(2)
Hi, after updating the version of React-Admin, I also began to see such a thing, it looks like a bug!Millesimal
You can suppress it by adding an empty key to your custom translation files: '': '', ...Millesimal
A
3

I have found that EditButton component is the cause. Adding label prop to it fixes the issue.

<EditButton label="Edit" />
Adroit answered 18/3, 2019 at 10:56 Comment(4)
Thanks..This is working for me also. But now Edit button column title has changed as 'Edit'. But I don't need title for that column in listing table. Do you have any solution for that?Romeo
You could pass an empty label, like label="". I have filed a bug here: github.com/marmelab/react-admin/issues/3017Gyno
But if I add label as empty (<EditButton label=""/>) then, Edit button text is not showing. Only the icon is there.Romeo
I getting this same warning even after adding the label value (using react-admin v2.9.4).Nullify
C
2

tl;dr

Check that your backend returns the proper response!

Explanation

The docs on response format state:

DELETE: { data: {Record|null} } The record that has been deleted (optional)

In our API the backend returned a simple HTTP 204 without a content (obviously). This caused the error:

Warning: Missing translation for key: "Cannot read property 'hasOwnProperty' of undefined"

Changing the response to be the deleted record fixed the issue.

Charie answered 20/10, 2019 at 1:41 Comment(0)
S
0

If you are also getting maximum call stack size exceeded with this error you may not be returning a not null value from your backend.

For instance, if you have a <TextField source="type" /> and type is required but you return a null value, then you will get this error. The solution is to either make it not required or to return a not null response.

Sophomore answered 6/4, 2019 at 17:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.