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

[fluent-react] Support ref forwarding in withLocalization #598

Open
akdetrick opened this issue Sep 7, 2022 · 1 comment
Open

[fluent-react] Support ref forwarding in withLocalization #598

akdetrick opened this issue Sep 7, 2022 · 1 comment

Comments

@akdetrick
Copy link

The withLocalization HOC is unable to forward refs to the wrapped component.

This would be useful for legacy projects that rely on class-based React components. The withLocalization HOC is the best option to provide the getString interface, but if the wrapped component relies on a ref being applied, withLocalization won't work.

There is an easy workaround, which is for developers to roll their own HOC that forwards a ref, composed from useLocalization. It may be a good feature to add to the official fluent react bindings.

i18next has a similar HOC, but supports an option to forward a ref through to the wrapped component: https://react.i18next.com/latest/withtranslation-hoc#use-ref-greater-than-v10.6.0

@eemeli
Copy link
Member

eemeli commented Sep 9, 2022

Yeah, that makes sense. Would you be willing/interested in submitting a PR for that, probably by adding an optional second arg like { forwardRef?: boolean } to withLocalization()?

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

2 participants