refactor(graphcontext): memoize context

This commit is contained in:
moklick
2019-08-05 14:41:38 +02:00
parent 8691edd3f4
commit b24d7b6704
6 changed files with 24 additions and 26 deletions
+8 -8
View File
@@ -30145,8 +30145,7 @@
var GraphContext = React.createContext({});
var Provider$1 = function Provider(props) {
var elements = props.elements,
children = props.children,
onConnect = props.onConnect;
children = props.children;
var _useReducer = React.useReducer(reducer, initialState),
_useReducer2 = _slicedToArray(_useReducer, 2),
@@ -30181,11 +30180,12 @@
dispatch(setEdges(edges));
}
});
var graphContext = {
state: state,
dispatch: dispatch,
onConnect: onConnect
};
var graphContext = React.useMemo(function () {
return {
state: state,
dispatch: dispatch
};
}, [state]);
return React__default.createElement(GraphContext.Provider, {
value: graphContext
}, children);
@@ -33135,7 +33135,7 @@
}, props));
});
TargetHandle.displayName = 'TargetHandle';
TargetHandle.whyDidYouRender = true;
TargetHandle.whyDidYouRender = false;
var SourceHandle = React.memo(function (props) {
var nodeId = React.useContext(NodeIdContext);