From 87cdb2c2a4eeeb7bb32fa91cd205094077ef0213 Mon Sep 17 00:00:00 2001 From: moklick Date: Mon, 22 Feb 2021 14:29:00 +0100 Subject: [PATCH] refactor(wrapper): memoize isWrapped --- src/container/ReactFlow/Wrapper.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/container/ReactFlow/Wrapper.tsx b/src/container/ReactFlow/Wrapper.tsx index 51480339..44db06ac 100644 --- a/src/container/ReactFlow/Wrapper.tsx +++ b/src/container/ReactFlow/Wrapper.tsx @@ -1,11 +1,13 @@ -import React, { FC, useContext } from 'react'; +import React, { FC, useContext, useMemo } from 'react'; import { Provider, ReactReduxContext } from 'react-redux'; import store from '../../store'; const Wrapper: FC = ({ children }) => { const contextValue = useContext(ReactReduxContext); - const isWrappedWithReactFlowProvider = contextValue?.store?.getState()?.reactFlowVersion; + const isWrappedWithReactFlowProvider = useMemo(() => contextValue?.store?.getState()?.reactFlowVersion, [ + contextValue, + ]); if (isWrappedWithReactFlowProvider) { // we need to wrap it with a fragment because t's not allowed for children to be a ReactNode