@applicaster/zapp-react-native-utils 16.0.0-rc.35 → 16.0.0-rc.36

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.
@@ -14,20 +14,14 @@ const { log_info } = createLogger({
14
14
  category: "General",
15
15
  });
16
16
 
17
- /**
18
- * Helper function to find the parent component in a component tree.
19
- */
20
- function findParentComponent(
21
- childId: string,
22
- parent: ZappRiver | ZappUIComponent
23
- ): ZappRiver | ZappUIComponent | null {
24
- for (const child of parent.ui_components) {
25
- if (child.id === childId) return parent;
17
+ /** Prefer component data.source, otherwise direct UIComponentContext parent. */
18
+ function getComponentFeedData(component) {
19
+ if (component?.data?.source) {
20
+ return component.data;
21
+ }
26
22
 
27
- if (child.ui_components) {
28
- const found = findParentComponent(childId, child);
29
- if (found) return found;
30
- }
23
+ if (component?.parent?.data?.source) {
24
+ return component.parent.data;
31
25
  }
32
26
 
33
27
  return null;
@@ -43,16 +37,7 @@ export const refreshComponentAction: ActionHandler = async (
43
37
  ): Promise<ActionResult> => {
44
38
  const dispatch = appStore.getDispatch();
45
39
 
46
- const parentComponent = findParentComponent(
47
- context?.component?.id,
48
- context?.screenData
49
- );
50
-
51
- const componentSource = context?.component?.data?.source;
52
-
53
- const componentData = componentSource
54
- ? context.component.data
55
- : parentComponent?.data;
40
+ const componentData = getComponentFeedData(context?.component);
56
41
 
57
42
  const source = componentData?.source;
58
43
  const mapping = componentData?.mapping;
@@ -16,8 +16,10 @@ export interface ActionExecutionContext {
16
16
  /** The entry that defines the screen (if screen was opened from an entry) */
17
17
  screenEntry?: ZappEntry;
18
18
 
19
- /** The UI component that triggered the action */
20
- component?: ZappUIComponent;
19
+ /** The UI component that triggered the action.
20
+ * From UIComponentContext as `{ ...component, parent }`.
21
+ */
22
+ component?: ZappUIComponent & { parent?: ZappUIComponent };
21
23
 
22
24
  /** The route identifier for the current screen */
23
25
  screenRoute?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "16.0.0-rc.35",
3
+ "version": "16.0.0-rc.36",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "homepage": "https://github.com/applicaster/quickbrick#readme",
29
29
  "dependencies": {
30
- "@applicaster/applicaster-types": "16.0.0-rc.35",
30
+ "@applicaster/applicaster-types": "16.0.0-rc.36",
31
31
  "buffer": "^5.2.1",
32
32
  "camelize": "^1.0.0",
33
33
  "dayjs": "^1.11.10",
@@ -4,6 +4,7 @@ import * as React from "react";
4
4
  import * as R from "ramda";
5
5
  import { handleActionSchemeUrl } from "@applicaster/quick-brick-core/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/useUrlSchemeHandler";
6
6
  import { CellTapContext } from "@applicaster/zapp-react-native-ui-components/Contexts/CellTapContext";
7
+ import { useUIComponentContext } from "@applicaster/zapp-react-native-ui-components/Contexts/UIComponentContext";
7
8
  import {
8
9
  useNavigation,
9
10
  useProfilerLogging,
@@ -28,7 +29,6 @@ import { useScreenStateStore } from "../navigation/useScreenStateStore";
28
29
  type Props = {
29
30
  item?: ZappEntry;
30
31
  index?: number;
31
- component?: ZappUIComponent;
32
32
  zappPipesData?: ZappPipesData;
33
33
  };
34
34
 
@@ -37,16 +37,16 @@ type onPressReturnFn =
37
37
  | (() => void);
38
38
 
39
39
  export const useCellClick = ({
40
- component,
41
40
  zappPipesData,
42
41
  item,
43
- }: Props): onPressReturnFn => {
42
+ }: Props = {}): onPressReturnFn => {
44
43
  const { push, currentRoute } = useNavigation();
45
44
  const { pathname } = useRoute();
46
45
  const screenStateStore = useScreenStateStore();
47
46
 
48
47
  const onCellTap: Option<Function> = React.useContext(CellTapContext);
49
48
  const actionExecutor = React.useContext(ActionExecutorContext);
49
+ const component = useUIComponentContext();
50
50
  const screenData = useCurrentScreenData();
51
51
  const screenState = useScreenContext()?.options;
52
52
  const entry = useScreenContext()?.entry;