Other Exports - Redux Toolkit
Other Exports - Redux Toolkit
Other Exports - Redux Toolkit
Other Exports
Redux Toolkit exports some of its internal utilities, and re-exports additional functions from
other dependencies as well.
nanoid
TypeScript JavaScript
console.log(nanoid())
// 'dgPXxUz_6fWIQBD8XmiSy'
miniSerializeError
copyWithStructuralSharing
https://redux-toolkit.js.org/api/other-exports 1/4
11/13/23, 4:45 PM Other Exports | Redux Toolkit
A utility that will recursively merge two similar objects together, preserving existing references
if the values appear to be the same. This is used internally to help ensure that re-fetched data
keeps using the same references unless the new data has actually changed, to avoid
unnecessary re-renders. Otherwise, every re-fetch would likely cause the entire dataset to be
replaced and all consuming components to always re-render.
If either of the inputs are not plain JS objects or arrays, the new value is returned.
The default immutable update function from the immer library, re-exported here as
createNextState (also commonly referred to as produce )
current
The current function from the immer library, which takes a snapshot of the current state of
a draft and finalizes it (but without freezing). Current is a great utility to print the current state
during debugging, and the output of current can also be safely leaked outside the producer.
TypeScript JavaScript
const initialState = []
https://redux-toolkit.js.org/api/other-exports 2/4
11/13/23, 4:45 PM Other Exports | Redux Toolkit
original
The original function from the immer library, which returns the original object. This is
particularly useful for referential equality check in reducers.
isDraft
The isDraft function from the immer library, which checks to see if a given value is a Proxy-
wrapped "draft" state.
freeze
The freeze function from the immer library, which freezes draftable objects.
combineReducers
compose
Redux's compose . It composes functions from right to left. This is a functional programming
utility. You might want to use it to apply several store custom enhancers/ functions in a row.
bindActionCreators
createStore
applyMiddleware
https://redux-toolkit.js.org/api/other-exports 3/4
11/13/23, 4:45 PM Other Exports | Redux Toolkit
https://redux-toolkit.js.org/api/other-exports 4/4