@applicaster/quick-brick-core 12.0.0-alpha.5812543239 → 12.0.0-alpha.6236157458

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,6 +1,7 @@
1
1
  import * as R from "ramda";
2
2
  import * as React from "react";
3
3
 
4
+ import { isEqual } from "@applicaster/zapp-react-native-utils/equalUtils";
4
5
  import { ThemeContext } from "@applicaster/zapp-react-native-utils/theme";
5
6
  import { useDimensions } from "@applicaster/zapp-react-native-utils/reactHooks";
6
7
  import {
@@ -80,16 +81,21 @@ const ThemeContextProvider = ({
80
81
  setSelectedThemeId,
81
82
  children,
82
83
  }: any) => {
83
- const value = React.useMemo(
84
- () => ({ themes, selectedThemeId, setSelectedThemeId }),
85
- [themes, selectedThemeId, setSelectedThemeId]
86
- );
84
+ const value = { themes, selectedThemeId, setSelectedThemeId };
87
85
 
88
86
  return (
89
87
  <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>
90
88
  );
91
89
  };
92
90
 
91
+ const MemoizedThemeContextProvider = React.memo(
92
+ ThemeContextProvider,
93
+ isEqual({
94
+ byValue: ["selectedThemeId", "setSelectedThemeId"],
95
+ byReference: ["children", "themes"],
96
+ })
97
+ );
98
+
93
99
  function ThemeManagerComponent({ children, plugins }: Props) {
94
100
  const dimensions = useDimensions("screen", { deviceInfo: true });
95
101
  const [themes, setThemes] = React.useState(selectThemes(dimensions, plugins));
@@ -98,18 +104,22 @@ function ThemeManagerComponent({ children, plugins }: Props) {
98
104
  React.useState(DEFAULT_THEME_ID);
99
105
 
100
106
  React.useEffect(() => {
101
- setThemes(selectThemes(dimensions, plugins));
107
+ setThemes((oldThemes) => {
108
+ const newThemes = selectThemes(dimensions, plugins);
109
+
110
+ return R.equals(oldThemes, newThemes) ? oldThemes : newThemes;
111
+ });
102
112
  }, [plugins, dimensions]);
103
113
 
104
114
  return (
105
- <ThemeContextProvider
115
+ <MemoizedThemeContextProvider
106
116
  themes={themes}
107
117
  selectedThemeId={selectedThemeId}
108
118
  setSelectedThemeId={setSelectedThemeId}
109
119
  >
110
120
  {children}
111
- </ThemeContextProvider>
121
+ </MemoizedThemeContextProvider>
112
122
  );
113
123
  }
114
124
 
115
- export const ThemeManager = React.memo<Props>(ThemeManagerComponent);
125
+ export const ThemeManager = ThemeManagerComponent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/quick-brick-core",
3
- "version": "12.0.0-alpha.5812543239",
3
+ "version": "12.0.0-alpha.6236157458",
4
4
  "description": "Core package for Applicaster's Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -30,13 +30,13 @@
30
30
  },
31
31
  "homepage": "https://github.com/applicaster/quickbrick#readme",
32
32
  "dependencies": {
33
- "@applicaster/applicaster-types": "12.0.0-alpha.5812543239",
34
- "@applicaster/quick-brick-core-plugins": "12.0.0-alpha.5812543239",
35
- "@applicaster/zapp-pipes-v2-client": "12.0.0-alpha.5812543239",
36
- "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.5812543239",
37
- "@applicaster/zapp-react-native-redux": "12.0.0-alpha.5812543239",
38
- "@applicaster/zapp-react-native-ui-components": "12.0.0-alpha.5812543239",
39
- "@applicaster/zapp-react-native-utils": "12.0.0-alpha.5812543239",
33
+ "@applicaster/applicaster-types": "12.0.0-alpha.6236157458",
34
+ "@applicaster/quick-brick-core-plugins": "12.0.0-alpha.6236157458",
35
+ "@applicaster/zapp-pipes-v2-client": "12.0.0-alpha.6236157458",
36
+ "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.6236157458",
37
+ "@applicaster/zapp-react-native-redux": "12.0.0-alpha.6236157458",
38
+ "@applicaster/zapp-react-native-ui-components": "12.0.0-alpha.6236157458",
39
+ "@applicaster/zapp-react-native-utils": "12.0.0-alpha.6236157458",
40
40
  "atob": "^2.1.2",
41
41
  "axios": "^0.21.2",
42
42
  "btoa": "^1.2.1",