Skip to content

Update @reduxjs/toolkit to v2 (with opt-in and v1 fallback)#235577

Draft
walterra wants to merge 14 commits intoelastic:mainfrom
walterra:update-redux-toolkit
Draft

Update @reduxjs/toolkit to v2 (with opt-in and v1 fallback)#235577
walterra wants to merge 14 commits intoelastic:mainfrom
walterra:update-redux-toolkit

Conversation

@walterra
Copy link
Contributor

@walterra walterra commented Sep 18, 2025

Summary

This PR replaces renovate PRs #206187 and #235548.

Fixes #239863.

Redux Toolkit V2 includes some breaking changes that will be quite an effort to fix in just one PR. Overall the use of redux and RTK is quite fragmented! Some parts use legacy redux style and might bring in other packages for selectors and alternatives to redux-thunk. Luckily there are more modern usages of RTK too.

Some new features/breaking changes:

  • createSlice comes with new features for inline selectors and thunks
  • combineSlices API with slice reducer injection for code-splitting, this could be quite useful to pick up for Kibana
  • V2 required to work with React v18 concurrent mode!
  • Redux Toolkit 2.0 is accompanied by major versions of all the other Redux packages: Redux core 5.0, React-Redux 9.0, Reselect 5.0, and Redux Thunk 3.0.
  • React-Redux 9.0 makes use of React 18’s native useSyncExternalStore to support concurrent mode.

Some of Kibana’s code base uses legacy redux style and that code might also be in maintenance mode with the aim to remove it at some point. We’d like to avoid spending lots of time updating that code base to use Redux Toolkit. Considering that, it might be worth enabling support for both RTK V1 and V2 for the time being. This would also allow teams to migrate gradually like we are able to do with React V18 concurrent mode.

This PR tries to do the following: Keep RTK V1 for the time being and allow to opt in to migrate to V2. This will have good developer experience for teams, since everyone can update their code base with separate PRs. The drawback is that we’d have to maintain packages aliases for RTK and all accompanying packages mentioned above until all legacy redux code is either removed or migrated. To have both versions will add 20-25Kbyte bundle size.

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

  • Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
  • Documentation was added for features that require explanation or tutorials
  • Unit or functional tests were updated or added to match the most common scenarios
  • If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list
  • This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The release_note:breaking label should be applied in these situations.
  • Flaky Test Runner was used on any tests changed
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.

Identify risks

Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging.

@elasticmachine
Copy link
Contributor

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!

@walterra walterra self-assigned this Sep 18, 2025
@walterra walterra added the dependencies Pull requests that update a dependency file label Sep 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update @reduxjs/toolkit to v2 (with opt-in and v1 fallback)

2 participants