@granite-js/react-native 0.1.12 → 0.1.13

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @granite-js/react-native
2
2
 
3
+ ## 0.1.13
4
+
5
+ ### Patch Changes
6
+
7
+ - 6838797: Make backEventState a singleton
8
+ - @granite-js/cli@0.1.13
9
+ - @granite-js/image@0.1.13
10
+ - @granite-js/jest@0.1.13
11
+ - @granite-js/lottie@0.1.13
12
+ - @granite-js/mpack@0.1.13
13
+ - @granite-js/native@0.1.13
14
+ - @granite-js/plugin-core@0.1.13
15
+ - @granite-js/style-utils@0.1.13
16
+
3
17
  ## 0.1.12
4
18
 
5
19
  ### Patch Changes
@@ -32,9 +32,8 @@ interface PrivateBackEventControls extends BackEventControls {
32
32
  * </BackEventProvider>
33
33
  * ```
34
34
  */
35
- export declare function BackEventProvider({ children, backEvent, }: {
35
+ export declare function BackEventProvider({ children }: {
36
36
  children: ReactNode;
37
- backEvent: PrivateBackEventControls;
38
37
  }): import("react/jsx-runtime").JSX.Element;
39
38
  /**
40
39
  * @name useBackEventState
@@ -128,8 +127,5 @@ export declare function useBackEventState(): PrivateBackEventControls;
128
127
  * ```
129
128
  */
130
129
  export declare function useBackEvent(): BackEventControls;
131
- export declare function useBackEventContext(): {
132
- onGoBack: () => void;
133
- hasBackEvent: boolean;
134
- };
130
+ export declare function useBackEventContext(): PrivateBackEventControls;
135
131
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@granite-js/react-native",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "The Granite Framework",
5
5
  "bin": {
6
6
  "granite": "./bin/cli.js"
@@ -74,7 +74,7 @@
74
74
  "@babel/core": "^7.24.9",
75
75
  "@babel/preset-env": "^7.24.8",
76
76
  "@babel/preset-typescript": "^7.24.7",
77
- "@granite-js/native": "0.1.12",
77
+ "@granite-js/native": "0.1.13",
78
78
  "@testing-library/dom": "^10.4.0",
79
79
  "@testing-library/react": "^16.1.0",
80
80
  "@types/babel__core": "^7",
@@ -100,13 +100,13 @@
100
100
  "react-native": "*"
101
101
  },
102
102
  "dependencies": {
103
- "@granite-js/cli": "0.1.12",
104
- "@granite-js/image": "0.1.12",
105
- "@granite-js/jest": "0.1.12",
106
- "@granite-js/lottie": "0.1.12",
107
- "@granite-js/mpack": "0.1.12",
108
- "@granite-js/plugin-core": "0.1.12",
109
- "@granite-js/style-utils": "0.1.12",
103
+ "@granite-js/cli": "0.1.13",
104
+ "@granite-js/image": "0.1.13",
105
+ "@granite-js/jest": "0.1.13",
106
+ "@granite-js/lottie": "0.1.13",
107
+ "@granite-js/mpack": "0.1.13",
108
+ "@granite-js/plugin-core": "0.1.13",
109
+ "@granite-js/style-utils": "0.1.13",
110
110
  "es-toolkit": "^1.39.8",
111
111
  "react-native-url-polyfill": "1.3.0"
112
112
  }
@@ -2,7 +2,7 @@ import { SafeAreaProvider } from '@granite-js/native/react-native-safe-area-cont
2
2
  import type { ComponentType, PropsWithChildren } from 'react';
3
3
  import type { InitialProps } from '../initial-props';
4
4
  import { Router } from '../router';
5
- import { BackEventProvider, useBackEventState } from '../use-back-event';
5
+ import { BackEventProvider } from '../use-back-event';
6
6
  import { App } from './App';
7
7
  import type { GraniteProps } from './Granite';
8
8
  import { getSchemePrefix } from '../utils/getSchemePrefix';
@@ -17,8 +17,6 @@ interface AppRootProps extends GraniteProps {
17
17
  }
18
18
 
19
19
  export function AppRoot({ appName, context, container: Container, initialProps, initialScheme, router }: AppRootProps) {
20
- const backEventState = useBackEventState();
21
-
22
20
  const prefix = getSchemePrefix({
23
21
  appName,
24
22
  scheme: global.__granite.app.scheme,
@@ -28,7 +26,7 @@ export function AppRoot({ appName, context, container: Container, initialProps,
28
26
  return (
29
27
  <App {...initialProps}>
30
28
  <SafeAreaProvider>
31
- <BackEventProvider backEvent={backEventState}>
29
+ <BackEventProvider>
32
30
  <Router
33
31
  context={context}
34
32
  initialProps={initialProps}
@@ -1,6 +1,6 @@
1
1
  import { NavigationContainerRefWithCurrent } from '@granite-js/native/@react-navigation/native';
2
2
  import { useCallback, useMemo } from 'react';
3
- import { useBackEventState } from '../../use-back-event';
3
+ import { useBackEventContext } from '../../use-back-event';
4
4
 
5
5
  /**
6
6
  * @public
@@ -63,7 +63,7 @@ export function useInternalRouterBackHandler({
63
63
  navigationContainerRef: NavigationContainerRefWithCurrent<any>;
64
64
  onClose?: () => void;
65
65
  }) {
66
- const { onBack, hasBackEvent } = useBackEventState();
66
+ const { hasBackEvent, onBack } = useBackEventContext();
67
67
  const canGoBack = !hasBackEvent;
68
68
 
69
69
  const handler = useCallback(() => {
@@ -38,14 +38,10 @@ const BackEventContext = createContext<PrivateBackEventControls | null>(null);
38
38
  * </BackEventProvider>
39
39
  * ```
40
40
  */
41
- export function BackEventProvider({
42
- children,
43
- backEvent,
44
- }: {
45
- children: ReactNode;
46
- backEvent: PrivateBackEventControls;
47
- }) {
48
- return <BackEventContext.Provider value={backEvent}>{children}</BackEventContext.Provider>;
41
+ export function BackEventProvider({ children }: { children: ReactNode }) {
42
+ const backEventState = useBackEventState();
43
+
44
+ return <BackEventContext.Provider value={backEventState}>{children}</BackEventContext.Provider>;
49
45
  }
50
46
 
51
47
  /**
@@ -253,8 +249,5 @@ export function useBackEventContext() {
253
249
  throw new Error('useBackEvent must be used within a BackEventProvider');
254
250
  }
255
251
 
256
- return {
257
- onGoBack: context.onBack,
258
- hasBackEvent: context.hasBackEvent,
259
- };
252
+ return context;
260
253
  }