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

cannot access static fetchData function after using withTranslation #800

Closed
zhouyuan1990 opened this issue Mar 23, 2019 · 10 comments
Closed

Comments

@zhouyuan1990
Copy link
Contributor

currently I'm trying to upgrade the react-i18next from v7 to v10.
we use static function to fetchData in server side like below:

let comp = renderProps.components[renderProps.components.length - 1].WrappedComponent
      if (comp !== undefined && comp.fetchData) {
        return comp.fetchData({ renderProps, store, history, res: res, req: req })
      } else {
        ...
      }

I try to change the translate to withTranslation, but it failed to access to the previous static fetchData.
How can I reach the static fetchData function?

@jamuhl
Copy link
Member

jamuhl commented Mar 23, 2019

@zhouyuan1990
Copy link
Contributor Author

Thanks for your quick reply 👍

@zhouyuan1990
Copy link
Contributor Author

hi @jamuhl
I just got another issue, that I always get ref as null after using withTranslation.
I have tried ref callback and createRef way (ref.current is also null).

@jamuhl
Copy link
Member

jamuhl commented Mar 23, 2019

not sure...never needed refs to much...

@zhouyuan1990
Copy link
Contributor Author

in previous version we have withRef to make it work.
no idea how to pass ref in this version.....

@jamuhl
Copy link
Member

jamuhl commented Mar 23, 2019

pass a prop innerRef to your component setting ref on the component needed...

@zhouyuan1990
Copy link
Contributor Author

Maybe withTranslation hoc can support forwardRef, to make it work?

@jamuhl
Copy link
Member

jamuhl commented Mar 24, 2019

You might add a PR? Not forget to add a test for the new feature.

@zhouyuan1990
Copy link
Contributor Author

#802
not sure if also need to add forwardRef for withSSR, since our project doesn't use withSSR, so I cannot verify if it works well in real project.

@jamuhl
Copy link
Member

jamuhl commented Mar 24, 2019

guess not needed on withSSR...still can add that when users ask for it...will review your PR tomorrow

@jamuhl jamuhl closed this as completed Mar 26, 2019
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