diff --git a/packages/renderer/src/page/block/Context.js b/packages/renderer/src/page/block/Context.js index 5bd8a32dc..b137636c1 100644 --- a/packages/renderer/src/page/block/Context.js +++ b/packages/renderer/src/page/block/Context.js @@ -21,10 +21,8 @@ import getContext from '@lowdefy/engine'; import OnEnter from './OnEnter'; -const contexts = {}; - const Context = ({ block, contextId, pageId, render, rootContext }) => { - const [loading, setLoading] = useState(true); + const [context, setContext] = useState({}); const [error, setError] = useState(null); useEffect(() => { @@ -38,8 +36,7 @@ const Context = ({ block, contextId, pageId, render, rootContext }) => { rootContext, }); if (mounted) { - contexts[contextId] = ctx; - setLoading(false); + setContext(ctx); } } catch (err) { setError(err); @@ -51,7 +48,7 @@ const Context = ({ block, contextId, pageId, render, rootContext }) => { }; }, [block, pageId, rootContext, contextId]); - if (loading) + if (context.id !== contextId) return ( { if (error) throw error; - return ; + return ; }; export default Context;