Why isn’t the React team putting in these enhancements?
Why isn’t the React team putting in these enhancements?
Anyway we are using it at prod and allowed us to reduce our bundle sizes ;)
This can be enforced with strict rules, eslint plugins and infra but they are expensive as hell.
EDIT: 'This will cause all consumers (with incorrect mapStateToProps configuration) to rerender'
https://react-redux.js.org/next/api/hooks#useselector
It is true that all of the selector functions need to run on each change, but those are supposed to be really small pure functions and their performance should be negligible, compared with everything else that normally happens in an app.
Edit: It is absolutely possible to affect performance with Redux, especially on a large app — for example if hundreds of selectors need to run for every keystroke in a textbox.
And yeah components are supposed to select only what they need in mapStateToProps and mapDispatchToProps. But I have seen a couple of instances where this is not followed and the developer chooses to use the entire state object passed to the component. This was fixed quickly and all developers got a short doc on the do's and dont's of Redux. This is what I mean by the extra work around redux library and not the concept itself.
Also its a fairly common to see developers pushing multiple micro updates like keystrokes to redux making it slow down. This gets filtered in the reviews but it misses out sometimes. I'm guessing this to happen in many other projects too unless I'm missing out on some major update on the tooling around redux.
These problems are not because of the approach but in the implementations. I hope you get what I mean by cost in my opinion above.