React-i18next: `tReady` is not a valid property for React (16.2.0)

Created on 18 Mar 2018  路  12Comments  路  Source: i18next/react-i18next

Warning: React does not recognize the tReady prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase tready instead. If you accidentally passed it from a parent component, remove it from the DOM element.

All 12 comments

on which element do you get that?

Oh sorry for the lack of context. Here is an example:

import { translate } from 'react-i18next';

const MyComponent = ({ children, ...props }) => (
  <div {...props}>
    {children}
  </div>
);

export default translate('myNamespace')(MyComponent);

And your "MyOtherComponent" is something like <div {...props}></div>

Yes. I edit, for a clearer example.

doing <div {...rest}> is something you should avoid...be explicit on what attributes you need on a DOM element.

do something like:

import { translate } from 'react-i18next';

const MyComponent = ({ children, ...rest }) => (
  <div {_.pick(...rest, ['style', 'otherOkProp']}>
    {children}
  </div>
);

export default translate('myNamespace')(MyComponent);

It makes sense. And if I need to forward t or tReady properties I'd rather forward them via data-t or data-tReady DOM attributes.

Same problem. I will destructure the tReady property from the properties.

Should tReady be added to the react-i18next DefinitelyTyped file?

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-i18next/src/props.d.ts

@onlydave should yes...the typescript definitions are maintained by the community...so you will have to create a PR there if like to have that in.

@jamuhl should tReady is always present and a boolean or is it optional?

and yes boolean true or false

Was this page helpful?
0 / 5 - 0 ratings

Related issues

simoami picture simoami  路  3Comments

Jessidhia picture Jessidhia  路  4Comments

oyeanuj picture oyeanuj  路  3Comments

pwiszowaty0 picture pwiszowaty0  路  4Comments

dawsbot picture dawsbot  路  4Comments