createSelector
mentioned at https://github.com/reduxjs/reselect
createSelector
API, which generates memoized selector functions. createSelector accepts one or more "input" selectors, which extract values from arguments, and an "output" selector that receives the extracted values and should return a derived value. If the generated selector is called multiple times, the output will only be recalculated when the extracted values have changed.
createDraftSafeSelector
mentioned at https://redux-toolkit.js.org/api/createSelector
createDraftSafeSelector
allows to create selectors that can safely be used inside ofcreateReducer
andcreateSlice
reducers with Immer-powered mutable logic. When used with plain state values, the selector will still memoize normally based on the inputs. But, when used with Immer draft values, the selector will err on the side of recalculating the results, just to be safe.
I am new to react and redux design patterns so could not understand the difference and purpose of createDraftSafeSelector
.
What is the difference in both API? What can be an example to understand the difference?