@plasmicapp/loader-react 1.0.80 → 1.0.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2140,44 +2140,48 @@ function PlasmicComponent(props) {
2140
2140
  throw new Error("You must use <PlasmicRootProvider/> at the root of your app");
2141
2141
  }
2142
2142
 
2143
- var lookup = rootContext.loader.getLookup();
2143
+ var loader = rootContext.loader,
2144
+ globalContextsProps = rootContext.globalContextsProps;
2144
2145
  var Component = usePlasmicComponent({
2145
2146
  name: component,
2146
2147
  projectId: projectId
2147
2148
  }, {
2148
2149
  forceOriginal: forceOriginal
2149
2150
  });
2151
+ var element = React.useMemo(function () {
2152
+ if (!Component) {
2153
+ return null;
2154
+ }
2150
2155
 
2151
- if (!Component) {
2152
- return null;
2153
- }
2154
-
2155
- var element = React.createElement(Component, Object.assign({}, componentProps));
2156
-
2157
- if (isRootLoader) {
2158
- // If this is the root PlasmicComponent, then wrap the content with the
2159
- // react-web's PlasmicRootProvider. We are doing this here, instead of
2160
- // say PlasmicRootProvider, because we don't have access to this context
2161
- // provider until data has been loaded. If we insert this provider into
2162
- // the tree at the root after data is loaded, then we'll invalidate the
2163
- // React tree and tree state, which is bad. Instead, we do it at the
2164
- // "root-most PlasmicComponent"; we won't risk invalidating the sub-tree
2165
- // here because there were no children before the data came in.
2166
- var ReactWebRootProvider = lookup.getRootProvider();
2167
- var GlobalContextsProvider = lookup.getGlobalContextsProvider({
2168
- name: component,
2169
- projectId: projectId
2170
- });
2171
- element = React.createElement(ReactWebRootProvider, null, React.createElement(MaybeWrap, {
2172
- cond: !!GlobalContextsProvider,
2173
- wrapper: function wrapper(children) {
2174
- return React.createElement(GlobalContextsProvider, Object.assign({}, rootContext.globalContextsProps), children);
2175
- }
2176
- }, React.createElement(PlasmicComponentContext.Provider, {
2177
- value: true
2178
- }, element)));
2179
- }
2156
+ var element = React.createElement(Component, Object.assign({}, componentProps));
2157
+
2158
+ if (isRootLoader) {
2159
+ // If this is the root PlasmicComponent, then wrap the content with the
2160
+ // react-web's PlasmicRootProvider. We are doing this here, instead of
2161
+ // say PlasmicRootProvider, because we don't have access to this context
2162
+ // provider until data has been loaded. If we insert this provider into
2163
+ // the tree at the root after data is loaded, then we'll invalidate the
2164
+ // React tree and tree state, which is bad. Instead, we do it at the
2165
+ // "root-most PlasmicComponent"; we won't risk invalidating the sub-tree
2166
+ // here because there were no children before the data came in.
2167
+ var lookup = loader.getLookup();
2168
+ var ReactWebRootProvider = lookup.getRootProvider();
2169
+ var GlobalContextsProvider = lookup.getGlobalContextsProvider({
2170
+ name: component,
2171
+ projectId: projectId
2172
+ });
2173
+ element = React.createElement(ReactWebRootProvider, null, React.createElement(MaybeWrap, {
2174
+ cond: !!GlobalContextsProvider,
2175
+ wrapper: function wrapper(children) {
2176
+ return React.createElement(GlobalContextsProvider, Object.assign({}, globalContextsProps), children);
2177
+ }
2178
+ }, React.createElement(PlasmicComponentContext.Provider, {
2179
+ value: true
2180
+ }, element)));
2181
+ }
2180
2182
 
2183
+ return element;
2184
+ }, [Component, componentProps, loader, isRootLoader, component, projectId, globalContextsProps]);
2181
2185
  return element;
2182
2186
  }
2183
2187