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

Keeping isReactComponent prototype #59

Closed
danbovey opened this issue Sep 6, 2018 · 1 comment
Closed

Keeping isReactComponent prototype #59

danbovey opened this issue Sep 6, 2018 · 1 comment

Comments

@danbovey
Copy link

danbovey commented Sep 6, 2018

Hi

I'm currently experiencing an issue passing a HOC directly to another component that is expecting the React Component to have .prototype.isReactComponent available. The HOC is react-intl and it's using this package to clone a WrappedComponent. The prototype property is added by React to allow others to easily check if a function is a React Component, which is used by react-table.

Seeing as this package is cloning React components, should this one prototype property be cloned too?

This current fix is to add this manaully before exporting:

const injected = injectIntl(MyComponent);
injected.prototype.isReactComponent = {};

export default injected
@mridgway
Copy link
Owner

mridgway commented Sep 6, 2018

Since this is a react specific property and not a static, I don't think it's right for this library to be hoisting it.

With that said, I don't see any reason why that property would not be available on an instance of the component since injectIntl is using a class that extends React.Component which defines that property.

I would also suggest not using that property on the prototype since it is subject to change as per Dan Abramov.

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