Home

Intro to Reselect

Quick and dirty implementation of reselect. This assumes you already have the requirements for Redux installed and in operation.

Dan Parker - Medium article

Basic example

yarn install reselect

// Reducer file import { createSelector } from 'reselect'; /* Selectors */ const getElementsUi = (state) => state.sidebarReducer.elementsUi; export const getElementsUiState = createSelector( [getElementsUi], (elementsUi) => elementsUi ); // In file calling mapStateToProps const mapStateToProps = (state) => ({ elementsUi: reducers.getElementsUiState(state) }); // Basic mapping dispatch const mapDispatchToProps = (dispatch) => ({ dispatch: dispatch }); // Basic wiring of program export default connect( mapStateToProps, mapDispatchToProps )(Component);

Repository

https://github.com/okeeffed/developer-notes-nextjs/content/redux/intro-to-reselect

Sections


Related