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

withI18n breaks static members #583

Closed
ghengeveld opened this issue Oct 26, 2018 · 4 comments
Closed

withI18n breaks static members #583

ghengeveld opened this issue Oct 26, 2018 · 4 comments

Comments

@ghengeveld
Copy link
Contributor

ghengeveld commented Oct 26, 2018

An example demonstrates this best:

import React from "react"
import { withI18n } from "react-i18next"

class Demo extends React.Component {
  static foo = "bar"
  render() {
    return <div />
  }
}

Demo.Member = () => <div />

console.log(Object.keys(Demo))             // => ["foo", "Member"]
console.log(Object.keys(withI18n()(Demo))) // => []

This essentially breaks access to static members of the wrapped component, which is often used to expose compound components.

I discovered this when using I18next with React Async, which uses compound components.

@ghengeveld
Copy link
Contributor Author

@jamuhl
Copy link
Member

jamuhl commented Oct 26, 2018

done for withNamespaces https://github.com/i18next/react-i18next/blob/master/src/withNamespaces.js#L56

feel free to provide a PR doing the same for withI18n

@ghengeveld
Copy link
Contributor Author

I'm writing a PR. Hold on.

@ghengeveld
Copy link
Contributor Author

Fixed it 👍

@jamuhl jamuhl closed this as completed in c075742 Oct 26, 2018
jamuhl added a commit that referenced this issue Oct 26, 2018
 Ensure withI18n hoists static members. Fixes #583.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants