From 6f663378e8525a9203b08a2030f7b86974d261ab Mon Sep 17 00:00:00 2001 From: Vladimir Gorej Date: Wed, 26 Jan 2022 17:12:37 +0100 Subject: [PATCH 1/2] fix(view-plugin): provide resolvers for memoized functions Refs #7800 --- src/core/plugins/view/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/plugins/view/index.js b/src/core/plugins/view/index.js index 0b360a7115b..33508a2cef0 100644 --- a/src/core/plugins/view/index.js +++ b/src/core/plugins/view/index.js @@ -5,7 +5,7 @@ import { getDisplayName } from "./fn" const viewPlugin = ({getComponents, getStore, getSystem}) => { // getComponent should be passed into makeMappedContainer, _already_ memoized... otherwise we have a big performance hit ( think, really big ) - const memGetComponent = memoize(getComponent(getSystem, getStore, getComponents)) + const memGetComponent = memoize(getComponent(getSystem, getStore, getComponents), (...args) => JSON.stringify(args)) const memMakeMappedContainer = memoize(withMappedContainer(getSystem, getStore, memGetComponent)) return { From 084fdaec698b5d05c81aa7c26db0b89d9262346b Mon Sep 17 00:00:00 2001 From: Vladimir Gorej Date: Thu, 27 Jan 2022 08:40:12 +0100 Subject: [PATCH 2/2] fix: mapped container --- src/core/plugins/view/index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/core/plugins/view/index.js b/src/core/plugins/view/index.js index 33508a2cef0..113f77ff968 100644 --- a/src/core/plugins/view/index.js +++ b/src/core/plugins/view/index.js @@ -2,11 +2,22 @@ import { memoize } from "core/utils" import { getComponent, render, withMappedContainer } from "./root-injects" import { getDisplayName } from "./fn" +import memoizeN from "../../../helpers/memoizeN" + +const memoizeForGetComponent = (fn) => { + const resolver = (...args) => JSON.stringify(args) + return memoize(fn, resolver) +} + +const memoizeForWithMappedContainer = (fn) => { + const resolver = (...args) => args + return memoizeN(fn, resolver) +} const viewPlugin = ({getComponents, getStore, getSystem}) => { // getComponent should be passed into makeMappedContainer, _already_ memoized... otherwise we have a big performance hit ( think, really big ) - const memGetComponent = memoize(getComponent(getSystem, getStore, getComponents), (...args) => JSON.stringify(args)) - const memMakeMappedContainer = memoize(withMappedContainer(getSystem, getStore, memGetComponent)) + const memGetComponent = memoizeForGetComponent(getComponent(getSystem, getStore, getComponents)) + const memMakeMappedContainer = memoizeForWithMappedContainer(withMappedContainer(getSystem, getStore, memGetComponent)) return { rootInjects: {