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

Property 'ns' does not exist on NamespacesConsumer type #568

Closed
jchu231 opened this issue Oct 23, 2018 · 3 comments
Closed

Property 'ns' does not exist on NamespacesConsumer type #568

jchu231 opened this issue Oct 23, 2018 · 3 comments

Comments

@jchu231
Copy link

jchu231 commented Oct 23, 2018

I have just updated to v8.1.0 to get your typescript defs, however I am running into this error:

TS2339: Property 'ns' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<NamespacesConsumerProps, ComponentState,...'.

This is caused by something like:

return(
  <NamespacesConsumer ns={[ 'translation', 'common' ]}>
  {( t: any, {i18n}: any ) => (
    <div>
      {t( 'common:dviText' )}
    </div>
  )}
  </NamespacesConsumer>
);

I am fairly new to Typescript, but is this syntax expected to be supported by the Typescript definitions? It is the syntax used in the react-i18next docs.

@jchu231 jchu231 changed the title Property 'ns' does not exist on NamespacesConsumer type [Typescript] Property 'ns' does not exist on NamespacesConsumer type Oct 23, 2018
@schettino
Copy link
Collaborator

schettino commented Oct 23, 2018

You're right, it hasn't been listed on the props list on docs, I missed it

@jchu231 jchu231 changed the title [Typescript] Property 'ns' does not exist on NamespacesConsumer type Property 'ns' does not exist on NamespacesConsumer type Oct 23, 2018
@schettino
Copy link
Collaborator

btw, you don't need to use any in {( t: any, {i18n}: any ) => (

just make sure you have added @types/i18next

@jchu231
Copy link
Author

jchu231 commented Oct 23, 2018

@schettino Thanks for the tip!

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

3 participants