From 31d5d15577559420ba7ed24370b705e1cce52227 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 17 Jan 2024 13:17:17 +0100 Subject: [PATCH] use useMount --- .../edit_transform_flyout_state.tsx | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/x-pack/plugins/transform/public/app/sections/edit_transform/state_management/edit_transform_flyout_state.tsx b/x-pack/plugins/transform/public/app/sections/edit_transform/state_management/edit_transform_flyout_state.tsx index 19851d0ef3e52..b79fbd55362f6 100644 --- a/x-pack/plugins/transform/public/app/sections/edit_transform/state_management/edit_transform_flyout_state.tsx +++ b/x-pack/plugins/transform/public/app/sections/edit_transform/state_management/edit_transform_flyout_state.tsx @@ -5,17 +5,11 @@ * 2.0. */ -import React, { - createContext, - useContext, - useEffect, - useMemo, - type FC, - type PropsWithChildren, -} from 'react'; +import React, { createContext, useContext, useMemo, type FC, type PropsWithChildren } from 'react'; import { configureStore, createSlice } from '@reduxjs/toolkit'; import { useDispatch, Provider } from 'react-redux'; import { bindActionCreators } from 'redux'; +import useMount from 'react-use/lib/useMount'; import type { TransformConfigUnion } from '../../../../../common/types/transform'; @@ -66,10 +60,9 @@ export const EditTransformFlyoutProvider: FC> = const store = useMemo(getReduxStore, []); // Apply original transform config to redux form state. - useEffect(() => { + useMount(() => { store.dispatch(editTransformFlyoutSlice.actions.initialize(props)); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + }); return (