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

Safe to ignore warning when exporting a react-redux connected component? #51

Closed
joshgreco opened this issue Oct 16, 2024 · 1 comment
Closed
Labels
enhancement New feature or request

Comments

@joshgreco
Copy link

This might be a really dumb question that belies my lack of understanding, but I'm getting the react-refresh/only-export-components warning when exporting a react-redux connected component like so:

export default connect(mapStateToProps, mapDispatchToProps)(MyComponent)

I'm wondering if its "safe" to ignore this warning? My understanding is that connect() returns a wrapper function which in turn returns a connected component. Is this technically an anonymous component?

The warning goes away if I change things to:

const ConnectedMyComponent = connect(mapStateToProps, mapDispatchToProps)(MyComponent);
export default ConnectedMyComponent;

But is that really doing anything besides circumventing the warning?

Thank you, and apologies if this is incredibly stupid of me to ask.

@ArnaudBarre
Copy link
Owner

That not stupid to ask. The rule can't be sure that this connect function returns a component and that this component will be correctly named (important for stack trace). I will verify that the component is correctly named and add an exception for this connect function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants