-
Notifications
You must be signed in to change notification settings - Fork 138
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
Connected components loses its original name #128
Comments
I think that losing the original name of the component is to be expected, since It's pretty easy to set the displayName of the Wrapper HOC to something more useful: --- a/src/integrations/preact.js
+++ b/src/integrations/preact.js
@@ -43,6 +43,7 @@ export function connect(mapStateToProps, actions) {
};
this.render = props => h(Child, assign(assign(assign({}, boundActions), props), state));
}
+ Wrapper.displayName = `connect(${Child.displayName || Child.name})`;
return (Wrapper.prototype = new Component()).constructor = Wrapper;
};
} But this causes an integration test to fail since unistore now compiles to a file which is larger than the 750B threshold specified by the test, so I don't know if I should open a PR or not (or even if this is the preferred approach to solve the problem). |
It seems that connecting a component will mean that it loses its original name. Down below is a test case where I was able to reproduce it.
The reason this is a problem for us is because we're using shallow render in some test cases to only render a certain amount of levels of depth to verify that a correct component was mounted, but unfortunately the name is lost unless we explicitly set
displayName
on the connected component before exporting and rendering it.EDIT: Forgot to mention that is using Preact.
The text was updated successfully, but these errors were encountered: