Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useNotify function throws warning to console (React admin 3.0.0-beta.3) #3903

Closed
panfiva opened this issue Oct 29, 2019 · 5 comments
Closed
Assignees

Comments

@panfiva
Copy link

panfiva commented Oct 29, 2019

The following code produces a warning in console about missing notification key. Need to be able to suppress disable translation service for custom notifications

const notify = useNotify();
notify("Notification Text", "info");

Console log will display a warning:
Warning: Missing translation for key: "Notification Text"
in Notification (created by Layout)
in Layout (created by WithStyles(Layout))
in WithStyles(Layout) (created by Router.Consumer)
in Router.Consumer (created by withRouter(WithStyles(Layout)))
in withRouter(WithStyles(Layout)) (created by Connect(withRouter(WithStyles(Layout))))
in Connect(withRouter(WithStyles(Layout))) (created by LayoutWithTheme)
in LayoutWithTheme (created by Router.Consumer)
in Router.Consumer (created by Route)
in Route (created by CoreAdminRouter)
in CoreAdminRouter (created by Router.Consumer)
in Router.Consumer (created by Route)
in Route (created by CoreAdmin)
in CoreAdmin (at App.js:26)
in App (at src/​index.js:14)

@WiXSL
Copy link
Contributor

WiXSL commented Oct 29, 2019

Maybe this can help you:
#3428 (comment)

@Kmaschta Kmaschta added the v3 label Oct 31, 2019
@fzaninotto
Copy link
Member

Even if useNotify is new in v3, the behavior was the same in v2 using the notification saga. And it was not a bug, but a feature. Except that this feature couldn't be disabled in v2, while it's possible to disable it in v3 (as exlained by @WiXSL).

So I'm flagging it as a documentation issue.

@fzaninotto
Copy link
Member

Fixed by #3930

@mihaildu
Copy link
Contributor

I would personally update all the places where useNotify is used as example to indicate that it tries to use a translated message, for example:
https://github.com/marmelab/react-admin/blob/master/docs/Actions.md (see notify('Comment approved'))
https://github.com/marmelab/react-admin/blob/master/docs/List.md
https://github.com/marmelab/react-admin/blob/master/docs/Authentication.md

Was about to open a new issue until I saw this :)

@brownieboy
Copy link

brownieboy commented Feb 15, 2020

It wasn't clear to me from @WiXSL's answer how to turn this off. I didnt know where to put the code that he's supplied and how to integrate it into my app.

I managed to piece it togther from his code and the ra-i18n-polyglot documentation.

You need to add this to your top level component; the one where you have imported the <Admin> component from react-admin:

import polyglotI18nProvider from "ra-i18n-polyglot";
import englishMessages from "ra-language-english";

const messages = {
  en: englishMessages
};

const i18nProvider = polyglotI18nProvider(locale => messages[locale], "en", {
  allowMissing: true
});

const App = () => (
  <Admin
    dataProvider={dataProvider}
    dashboard={Dashboard}
    authProvider={AuthProvider(authConfig)}
    locale="en"  // Add this...
    i18nProvider={i18nProvider}  // ... and this
  >

That was a fair bit of time to work out how to tame a feature that I never needed to be turned on in the first place. Still, once it's done, it's done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants