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

Refactor redux selectors #53

Closed
Ligerx opened this issue May 28, 2019 · 2 comments · Fixed by #58
Closed

Refactor redux selectors #53

Ligerx opened this issue May 28, 2019 · 2 comments · Fixed by #58

Comments

@Ligerx
Copy link
Owner

Ligerx commented May 28, 2019

First, architecturally, use selectors to pull data from the store instead of directly doing it from mapStateToProps
Then consider using something like reselect for computed values. You only need reselect for computed values as non-computed values are already optimized by react-redux. However there are some complications with reselect depending on how you want to use it.

I think using the prefix select... makes sense. eg. selectLibrary, but willing to consider other naming conventions like getLibrary or librarySelector

Readings:
https://medium.com/@matthew.holman/what-is-a-redux-selector-a517acee1fe8
https://read.reduxbook.com/markdown/part1/07-selectors.html
https://twitter.com/dan_abramov/status/664581975764766721?lang=en
https://medium.com/@kylpo/redux-best-practices-eef55a20cc72
https://medium.com/@parkerdan/react-reselect-and-redux-b34017f8194c
https://medium.com/@pearlmcphee/selectors-react-redux-reselect-9ab984688dd4
https://redux.js.org/recipes/computing-derived-data#selectors-todoselectorsjs
https://tech.residebrokerage.com/how-we-reselect-and-you-can-to-7e7ed23a8c6f
https://blog.isquaredsoftware.com/2017/12/idiomatic-redux-using-reselect-selectors/

https://github.com/toomuchdesign/re-reselect

and some redux optimization guides
https://spin.atomicobject.com/2018/04/02/redux-rerendering/
https://itnext.io/redux-ruins-you-react-app-performance-you-are-doing-something-wrong-82e28ec96cf5
https://medium.com/voobans-tech-stories/5-ways-to-stop-wasting-renders-in-react-redux-73b3c5d86f50

@Ligerx
Copy link
Owner Author

Ligerx commented May 28, 2019

re-reselect does seem to get around some of those annoyances I mentioned above. Read through some of the examples to see how it abstracts away the stupid code

@Ligerx
Copy link
Owner Author

Ligerx commented Jun 4, 2019

Also look into using selectors for any data source that gets sorted or filtered. #63

@Ligerx Ligerx closed this as completed in #58 Jun 5, 2019
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

Successfully merging a pull request may close this issue.

1 participant