Redux

GitbookGatsby2021-01-05


πŸ“‘ object expression


It’s important to wrap it in parents, so that parser understands this as an expression rather than a block.

Also, it can be nicer to use the concise method notation inside mapdispatchtoprops, instead of arrow functions because it’s harder.

const mapDispatchToProps = (dispatch) => ({
	onTodoClick(id) {
		dispatch({ type: "TOGGLE_TODO", id });
	},
});

πŸ“‘ Redux


  • combineReducers
  • applyMiddleware
  • bindActionCreators
  • compose
  • Provider
  • connect
  • createStore
  • Store
type Store = {
	dispatch: Dispatch;
	getState: () => State;
	subscribe: (listener: () => void) => () => void;
	replaceReducer: (reducer: Reducer) => void;
};

πŸͺ• Store


  • Nodes gatsby-source-filesystem
  • Schema GraphQL schema inferred(ζŽ¨ζ–­) from Nodes
  • Pages Map: path, component, context
  • Components: Map
  • Static Query Components: Map