Reading Notes
What’s the best practice for “pre-loading” data into the store (on application start) in a Redux application? Create an initial state that is immutable.
When using a thunk/async action that dispatches the actual action, which do you export from your reducer? A function
configureStore()
provides simplified config options, combine slice reducers, adds Redux middleware, includes Redux-thunkcreateReducer()
supply a lookup table of action types to case reducer functions, uses immer
library to let you write simpler immutable updatescreateAction()
generates an action creator function for the given action type stringcreateSlice()
accepts an object of reducer functions, a slice name, and an initial state value, creates a slice reducer with corresponding action creators and action typescreateAsyncThunk
accepts an action type string and a function that returns a promise, generates a thunk that dispatches action based on promisecreateEntityAdaptor
generates set of reusable reducers adn selectors to manage normalized data in the storecreateSelector
utility from Reselect
library re-exported for ease of usenpm install @reduxjs/toolkit
createSlice
and createReducer
wrap function with produce
from Immer
library. Can write code that mutates code inside reducer and Immer will return a correct immutably updated resultducks
pattern: “put all action creators and reducers in one file, do named exports of the action creators, and default export of reducer function”autorun
automatically creates a reaction that runs once and whenever the observable data inside the function changesobserver
wrapping used to rerender specific code whenever relevant state changesimport { makeAutoObservable } from "mobx"
import { observer } from "mobx-react"
npm install --save @hookstate/core