-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Please hoist statics in injectIntl #1047
Comments
As a temporary fix, people can use this custom import { injectIntl as baseInjectIntl } from 'react-intl';
import hoistNonReactStatic from 'hoist-non-react-statics';
/**
* A fixed injectIntl that hoists statics.
*/
export function injectIntl(WrappedComponent: Function): Function {
const WrapperComponent = baseInjectIntl(WrappedComponent);
hoistNonReactStatic(WrapperComponent, WrappedComponent);
return WrapperComponent;
} |
Having |
bringking
added a commit
to GhostGroup/react-intl
that referenced
this issue
Jun 20, 2018
manpreetnarang
added a commit
to blongg/react-intl
that referenced
this issue
Jul 18, 2018
formatjs#1047 Hoist non-react statics in injectIntl
redonkulus
pushed a commit
that referenced
this issue
Sep 6, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected behavior
statics are hoisted
Current behavior
statics are not being hoisted
This is breaking stuff for some libraries such as react-navigation, that use:
Solution
use
hoist-non-react-statics
as described here: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-overThis issue is further described at react-navigation/react-navigation#332
An example solution can be viewed here:
https://github.com/ReactTraining/react-router/blob/master/packages/react-router/modules/withRouter.js
The text was updated successfully, but these errors were encountered: