Skip to content

fix(combineSlices): Infer PreloadedState properly from provided slice - #5125

Merged
markerikson merged 2 commits into
masterfrom
combineslices-preloadedstate
Nov 3, 2025
Merged

markerikson merged 2 commits into
masterfrom
combineslices-preloadedstate

Conversation

@EskiMojo14

@EskiMojo14 EskiMojo14 commented Oct 31, 2025 •

Copy link
Copy Markdown
Collaborator

Currently combineSlices does not account for reducers that can receive different state than they return.

The most common example of this would be a reducer that's been through persistReducer, as they can receive an object without the _persist key, but will always return one. combineSlices' current types only care about what's returned, so will always require that _persist key to be passed as part of preloadedState.

declare const baseReducer: Reducer<{ foo: boolean }>

const persistedReducer = persistReducer(baseReducer)

const rootReducer = combineSlices({ bar: persistedReducer });

rootReducer({ bar: { foo: true } }, { type: "" }) // should be allowed, but errors saying _persist is missing

@codesandbox

codesandbox Bot commented Oct 31, 2025

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web Editor • VS Code • Insiders

Open Preview

@codesandbox-ci

codesandbox-ci Bot commented Oct 31, 2025 •

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit e99debb:

Sandbox Source
@examples-action-listener/counter Configuration
rtk-esm-cra Configuration

@netlify

netlify Bot commented Oct 31, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for redux-starter-kit-docs ready!

Name Link
🔨 Latest commit e99debb
🔍 Latest deploy log https://app.netlify.com/projects/redux-starter-kit-docs/deploys/6904e2b94fc31700088db677
😎 Deploy Preview https://deploy-preview-5125--redux-starter-kit-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

github-actions Bot commented Oct 31, 2025 •

Copy link
Copy Markdown

size-limit report 📦

Path Size

@EskiMojo14
EskiMojo14 force-pushed the combineslices-preloadedstate branch from 3c9f9ad to e99debb Compare October 31, 2025 16:24
@markerikson
markerikson merged commit e102997 into master Nov 3, 2025
@aryaemami59
aryaemami59 deleted the combineslices-preloadedstate branch March 18, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants