@pack/react 0.0.10 → 0.0.12

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.
@@ -1 +1 @@
1
- {"version":3,"file":"use-customizer-shell.d.ts","sourceRoot":"","sources":["../src/use-customizer-shell.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,mFAM5B,GAAG;;;CAkHL,CAAC"}
1
+ {"version":3,"file":"use-customizer-shell.d.ts","sourceRoot":"","sources":["../src/use-customizer-shell.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,mFAM5B,GAAG;;;CA0HL,CAAC"}
@@ -1,4 +1,4 @@
1
- import { useCallback, useEffect, useState } from "react";
1
+ import { useCallback, useEffect, useMemo, useState } from "react";
2
2
  import { connectToParent, ErrorCode } from "penpal";
3
3
  export const useCustomizerShell = ({ environment = "production", isPreview, sectionComponents, data = {}, storefrontSettingsSchema, }) => {
4
4
  const [location, setLocation] = useState();
@@ -35,7 +35,14 @@ export const useCustomizerShell = ({ environment = "production", isPreview, sect
35
35
  if (!storefrontSettingsSchema || !parentConnection || !sectionComponents) {
36
36
  return [];
37
37
  }
38
- parentConnection.setStorefrontSettingsSchema(JSON.stringify(storefrontSettingsSchema));
38
+ try {
39
+ parentConnection.setStorefrontSettingsSchema(JSON.stringify(storefrontSettingsSchema));
40
+ }
41
+ catch (error) {
42
+ if (error.code !== ErrorCode.ConnectionDestroyed) {
43
+ parentConnection?.displayError("Something went wrong parsing sections");
44
+ }
45
+ }
39
46
  return;
40
47
  // eslint-disable-next-line react-hooks/exhaustive-deps
41
48
  }, [data.handle, parentConnection, storefrontSettingsSchema]);
@@ -94,5 +101,7 @@ export const useCustomizerShell = ({ environment = "production", isPreview, sect
94
101
  storefrontSettings: data.settings?.settings,
95
102
  };
96
103
  }
97
- return { content, storefrontSettings };
104
+ return useMemo(() => {
105
+ return { content, storefrontSettings };
106
+ }, [content, storefrontSettings]);
98
107
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pack/react",
3
3
  "description": "React",
4
- "version": "0.0.10",
4
+ "version": "0.0.12",
5
5
  "exports": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "engines": {