diff --git a/x-pack/plugins/cases/public/components/cases_context/index.tsx b/x-pack/plugins/cases/public/components/cases_context/index.tsx index e5bf4ea8e5415..34d2b342c572c 100644 --- a/x-pack/plugins/cases/public/components/cases_context/index.tsx +++ b/x-pack/plugins/cases/public/components/cases_context/index.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React, { useState, useEffect, useReducer, useMemo } from 'react'; +import React, { useState, useEffect, useReducer } from 'react'; import { merge } from 'lodash'; import { DEFAULT_FEATURES } from '../../../common/constants'; import { DEFAULT_BASE_PATH } from '../../common/navigation'; @@ -46,18 +46,17 @@ export const CasesProvider: React.FC<{ value: CasesContextProps }> = ({ }) => { const { appId, appTitle } = useApplication(); const [state, dispatch] = useReducer(casesContextReducer, initialCasesContextState()); - const [baseValue, setBaseValue] = useState>( - () => ({ - owner, - userCanCrud, - basePath, - /** - * The empty object at the beginning avoids the mutation - * of the DEFAULT_FEATURES object - */ - features: merge({}, DEFAULT_FEATURES, features), - }) - ); + const [value, setValue] = useState(() => ({ + owner, + userCanCrud, + basePath, + /** + * The empty object at the beginning avoids the mutation + * of the DEFAULT_FEATURES object + */ + features: merge({}, DEFAULT_FEATURES, features), + dispatch, + })); /** * `userCanCrud` prop may change by the parent plugin. @@ -66,7 +65,7 @@ export const CasesProvider: React.FC<{ value: CasesContextProps }> = ({ */ useEffect(() => { if (appId && appTitle) { - setBaseValue((prev) => ({ + setValue((prev) => ({ ...prev, appId, appTitle, @@ -75,10 +74,6 @@ export const CasesProvider: React.FC<{ value: CasesContextProps }> = ({ } }, [appTitle, appId, userCanCrud]); - const value = useMemo(() => { - return { ...baseValue, dispatch }; - }, [baseValue]); - return isCasesContextValue(value) ? (