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

children.type === Target may not reliable #1

Open
yuxuan opened this issue May 27, 2019 · 1 comment
Open

children.type === Target may not reliable #1

yuxuan opened this issue May 27, 2019 · 1 comment

Comments

@yuxuan
Copy link

yuxuan commented May 27, 2019

According to this issue gaearon/react-hot-loader#304, tools/libs such as react-hot-loader that returns proxy components instead of original ones, using children.type === Target would result false. We can use:

const TargetType = <Target />.type;
...
children.type === TargetType; 

to record proxy component type and compare with that.

The problem of this solution is if there are required props in Target component, there will be warnings.

There are also other proposed fixes, such as gaearon/react-proxy#68

@yuxuan
Copy link
Author

yuxuan commented May 27, 2019

You can't use children.type.name === 'Target' either. Even thought the component is not been proxied, minify would change function.name.

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

1 participant