Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade redux toolkit to 2.2.2 #178986

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@
"@opentelemetry/sdk-metrics-base": "^0.31.0",
"@opentelemetry/semantic-conventions": "^1.4.0",
"@paralleldrive/cuid2": "^2.2.2",
"@reduxjs/toolkit": "1.9.7",
"@reduxjs/toolkit": "2.2.2",
"@slack/webhook": "^7.0.1",
"@smithy/eventstream-codec": "^2.0.12",
"@smithy/eventstream-serde-node": "^2.1.1",
Expand Down Expand Up @@ -999,7 +999,7 @@
"https-proxy-agent": "^5.0.1",
"i18n-iso-countries": "^4.3.1",
"icalendar": "0.7.1",
"immer": "^9.0.21",
"immer": "^10.0.3",
"inquirer": "^7.3.3",
"intl": "^1.2.5",
"intl-format-cache": "^2.1.0",
Expand Down Expand Up @@ -1086,7 +1086,7 @@
"react-monaco-editor": "^0.54.0",
"react-popper-tooltip": "^3.1.1",
"react-recompose": "^0.33.0",
"react-redux": "^7.2.8",
"react-redux": "^8.1.3",
"react-resizable": "^3.0.4",
"react-reverse-portal": "^2.1.0",
"react-router": "^5.3.4",
Expand All @@ -1099,18 +1099,18 @@
"react-virtualized": "^9.22.5",
"react-window": "^1.8.9",
"reduce-reducers": "^1.0.4",
"redux": "^4.2.1",
"redux": "^5.0.1",
"redux-actions": "^2.6.5",
"redux-devtools-extension": "^2.13.8",
"redux-saga": "^1.1.3",
"redux-thunk": "^2.4.2",
"redux-devtools-extension": "^2.13.9",
"redux-saga": "^1.3.0",
"redux-thunk": "^3.1.0",
"redux-thunks": "^1.0.0",
"reflect-metadata": "^0.2.1",
"remark-gfm": "1.0.0",
"remark-parse-no-trim": "^8.0.4",
"remark-stringify": "^8.0.3",
"require-in-the-middle": "^7.2.1",
"reselect": "^4.1.8",
"reselect": "^5.0.1",
"resize-observer-polyfill": "1.5.1",
"rison-node": "1.0.2",
"rxjs": "^7.5.5",
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-expandable-flyout/src/redux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { initialState, State } from './state';
export const store = configureStore({
reducer,
devTools: process.env.NODE_ENV !== 'production',
enhancers: [],
});

export const Context = createContext<ReactReduxContextValue<State>>({
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-expandable-flyout/src/test/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const TestProvider: FC<PropsWithChildren<TestProviderProps>> = ({
reducer,
devTools: false,
preloadedState: state,
enhancers: [],
});

return (
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/embeddable/public/store/create_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function createReducer<S extends State>(
reducer?: CreateStoreOptions<S>['reducer']
): Reducer<S> | ReducersMapObject<S> {
if (reducer instanceof Function) {
const generic = combineReducers<Pick<S, keyof State>>({
const generic = combineReducers({
input: input.reducer,
output: output.reducer,
}) as Reducer<S>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import PropTypes from 'prop-types';
import { connectAdvanced } from 'react-redux';
import { connect } from 'react-redux';
import { compose, withPropsOnChange, mapProps } from 'react-recompose';
import isEqual from 'react-fast-compare';
import { getResolvedArgs, getSelectedPage } from '../../state/selectors/workpad';
Expand Down Expand Up @@ -57,7 +57,7 @@ function selectorFactory(dispatch) {
}

export const ElementWrapper = compose(
connectAdvanced(selectorFactory),
connect(selectorFactory),
withPropsOnChange(
(props, nextProps) => !isEqual(props.element, nextProps.element),
(props) => {
Expand Down
6 changes: 2 additions & 4 deletions x-pack/plugins/canvas/public/state/middleware/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
*/

import { applyMiddleware, compose as reduxCompose } from 'redux';
import thunkMiddleware from 'redux-thunk';
import { thunk } from 'redux-thunk';
import { getWindow } from '../../lib/get_window';
import { inFlight } from './in_flight';
import { workpadUpdate } from './workpad_update';
import { elementStats } from './element_stats';
import { resolvedArgs } from './resolved_args';

const middlewares = [
applyMiddleware(thunkMiddleware, elementStats, resolvedArgs, inFlight, workpadUpdate),
];
const middlewares = [applyMiddleware(thunk, elementStats, resolvedArgs, inFlight, workpadUpdate)];

// compose with redux devtools, if extension is installed
const compose = getWindow().__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || reduxCompose;
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/canvas/storybook/addon/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { applyMiddleware, Dispatch, Store } from 'redux';
import thunkMiddleware from 'redux-thunk';
import { thunk } from 'redux-thunk';
import addons from '@storybook/addons';
import { diff } from 'jsondiffpatch';
import { isFunction } from 'lodash';
Expand All @@ -21,7 +21,7 @@ import { getInitialState as getState } from '../../public/state/initial_state';
import { State } from '../../types';

export const getInitialState: () => State = () => getState();
export const getMiddleware = () => applyMiddleware(thunkMiddleware);
export const getMiddleware = () => applyMiddleware(thunk);
export const getReducer = () => getRootReducer(getInitialState());

export const patchDispatch: (store: Store, dispatch: Dispatch) => Dispatch =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { applyMiddleware, compose, createStore } from 'redux';
import thunk from 'redux-thunk';
import { thunk } from 'redux-thunk';

import { ccr } from './reducers';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import { thunk } from 'redux-thunk';
import { defaultTableState } from './reducers/table_state';

import { getReducer } from './reducers';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import { thunk } from 'redux-thunk';

import { licenseManagement } from './reducers';

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/maps/public/reducers/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { combineReducers, applyMiddleware, createStore, compose } from 'redux';
import thunk from 'redux-thunk';
import { thunk } from 'redux-thunk';
import { ui, DEFAULT_MAP_UI_STATE } from './ui';
import { map, DEFAULT_MAP_STATE } from './map'; // eslint-disable-line import/named
import { nonSerializableInstances } from './non_serializable_instances';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const store = configureStore({
middleware: (getDefaultMiddleware) => getDefaultMiddleware({ thunk: false }).concat(sagaMW),
devTools: process.env.NODE_ENV !== 'production',
preloadedState: {},
enhancers: [],
});

sagaMW.run(rootEffect);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import { thunk } from 'redux-thunk';

import { remoteClusters } from './reducers';
import { detailPanel } from './middleware';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/rollup/public/crud_app/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import { thunk } from 'redux-thunk';

import { rollupJobs } from './reducers';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { createSelector } from 'reselect';
import { createSelector, lruMemoize } from 'reselect';
import type { State } from '../types';
import type { SourcererModel } from './model';
import { SourcererScopeName } from './model';
Expand All @@ -23,13 +23,15 @@ export const sourcererScope = createSelector(
(state: State, scopeId: SourcererScopeName) => scopeId,
(scopes, scopeId) => scopes[scopeId],
{
memoize: lruMemoize,
memoizeOptions: {
maxSize: SOURCERER_SCOPE_MAX_SIZE,
},
}
);

export const sourcererScopeIsLoading = createSelector(sourcererScope, (scope) => scope.loading, {
memoize: lruMemoize,
memoizeOptions: {
maxSize: SOURCERER_SCOPE_MAX_SIZE,
},
Expand All @@ -39,6 +41,8 @@ export const sourcererScopeSelectedDataViewId = createSelector(
sourcererScope,
(scope) => scope.selectedDataViewId,
{
memoize: lruMemoize,

memoizeOptions: {
maxSize: SOURCERER_SCOPE_MAX_SIZE,
},
Expand All @@ -49,6 +53,7 @@ export const sourcererScopeSelectedPatterns = createSelector(
sourcererScope,
(scope) => scope.selectedPatterns,
{
memoize: lruMemoize,
memoizeOptions: {
maxSize: SOURCERER_SCOPE_MAX_SIZE,
},
Expand All @@ -59,6 +64,7 @@ export const sourcererScopeMissingPatterns = createSelector(
sourcererScope,
(scope) => scope.missingPatterns,
{
memoize: lruMemoize,
memoizeOptions: {
maxSize: SOURCERER_SCOPE_MAX_SIZE,
},
Expand All @@ -69,6 +75,7 @@ export const kibanaDataViews = createSelector(
selectSourcerer,
(sourcerer) => sourcerer.kibanaDataViews,
{
memoize: lruMemoize,
memoizeOptions: {
maxSize: SOURCERER_SCOPE_MAX_SIZE,
},
Expand All @@ -79,6 +86,7 @@ export const defaultDataView = createSelector(
selectSourcerer,
(sourcerer) => sourcerer.defaultDataView,
{
memoize: lruMemoize,
memoizeOptions: {
maxSize: SOURCERER_SCOPE_MAX_SIZE,
},
Expand All @@ -89,6 +97,7 @@ export const signalIndexName = createSelector(
selectSourcerer,
(sourcerer) => sourcerer.signalIndexName,
{
memoize: lruMemoize,
memoizeOptions: {
maxSize: SOURCERER_SCOPE_MAX_SIZE,
},
Expand All @@ -99,6 +108,7 @@ export const signalIndexMappingOutdated = createSelector(
selectSourcerer,
(sourcerer) => sourcerer.signalIndexMappingOutdated,
{
memoize: lruMemoize,
memoizeOptions: {
maxSize: SOURCERER_SCOPE_MAX_SIZE,
},
Expand Down
Loading