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

Avoiding no-shadow eslint error #332

Closed
johncantrell97 opened this issue Jan 24, 2020 · 1 comment
Closed

Avoiding no-shadow eslint error #332

johncantrell97 opened this issue Jan 24, 2020 · 1 comment

Comments

@johncantrell97
Copy link

In the intermediate tutorial you showcase a really common pattern of importing an action creator from a slice and then map it to props using connect(). I'm struggling to decide what the right way to handle this is. Since redux-toolkit seems to have some strong opinions I was hoping for one about this topic.

There's a great answer on SO about this same topic ( https://stackoverflow.com/a/42337137 ).

I'm leaning towards his #1 solution of just disabling this eslint rule in my project. His #3 violates react/destructuring-assignment eslint rule.

Only other option imo is #2 where you rename the connected action creator with some strict naming convention but that just doesn't feel great to me either.

What do the folks here recommend? Based on the tutorial it seems you would also lean towards just allowing variable shadowing in this case?

@markerikson
Copy link
Collaborator

I'd say that answer is a lot more thorough than anything I could offer on this topic :)

Personally, the "shadowing" thing has never been a point of concern for me, and not a rule I've ever actually used.

As Dan has commented a number of times: lint rules are supposed to help you, not annoy you. Disable rules that aren't actually providing value.

Note that this isn't an issue with our React-Redux hooks API, as there's no action creator binding going on. See the Advanced Tutorial for examples of using that.

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