@cactuslab/native-navigation-react
Advanced tools
Comparing version 4.1.0 to 5.0.0
@@ -56,3 +56,3 @@ import type { ClickEventData, DismissOptions, DismissResult, TabUpdate, ViewUpdate } from '@cactuslab/native-navigation'; | ||
export declare function NativeNavigationViewContextProvider(props: React.PropsWithChildren<NativeNavigationViewProps>): React.JSX.Element; | ||
export declare function useNativeNavigationViewContext(): NativeNavigationViewContext; | ||
export declare function useNativeNavigationViewContext(options?: ViewUpdate): NativeNavigationViewContext; | ||
export {}; |
@@ -12,3 +12,4 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
}; | ||
import React, { useContext, useMemo } from 'react'; | ||
import React, { useContext, useLayoutEffect, useMemo, useRef } from 'react'; | ||
import equal from 'fast-deep-equal'; | ||
import { useNativeNavigation } from './internal'; | ||
@@ -140,5 +141,14 @@ function createViewContext(options) { | ||
} | ||
export function useNativeNavigationViewContext() { | ||
return useContext(Context); | ||
export function useNativeNavigationViewContext(options) { | ||
const context = useContext(Context); | ||
const previousOptions = useRef(); | ||
/* We want to update the options before layout occurs */ | ||
useLayoutEffect(function () { | ||
if (options && !equal(options, previousOptions.current)) { | ||
previousOptions.current = options; | ||
context.updateView(Object.assign(Object.assign({}, options), { animated: false })); | ||
} | ||
}, [context, options]); | ||
return context; | ||
} | ||
//# sourceMappingURL=context.js.map |
@@ -5,2 +5,3 @@ 'use strict'; | ||
var React = require('react'); | ||
var equal = require('fast-deep-equal'); | ||
var reactDom = require('react-dom'); | ||
@@ -444,4 +445,13 @@ | ||
} | ||
function useNativeNavigationViewContext() { | ||
return React.useContext(Context); | ||
function useNativeNavigationViewContext(options) { | ||
const context = React.useContext(Context); | ||
const previousOptions = React.useRef(); | ||
/* We want to update the options before layout occurs */ | ||
React.useLayoutEffect(function () { | ||
if (options && !equal(options, previousOptions.current)) { | ||
previousOptions.current = options; | ||
context.updateView(Object.assign(Object.assign({}, options), { animated: false })); | ||
} | ||
}, [context, options]); | ||
return context; | ||
} | ||
@@ -448,0 +458,0 @@ |
@@ -1,2 +0,2 @@ | ||
var CapacitorNativeNavigationReact = (function (exports, nativeNavigation, React, reactDom) { | ||
var CapacitorNativeNavigationReact = (function (exports, nativeNavigation, React, equal, reactDom) { | ||
'use strict'; | ||
@@ -440,4 +440,13 @@ | ||
} | ||
function useNativeNavigationViewContext() { | ||
return React.useContext(Context); | ||
function useNativeNavigationViewContext(options) { | ||
const context = React.useContext(Context); | ||
const previousOptions = React.useRef(); | ||
/* We want to update the options before layout occurs */ | ||
React.useLayoutEffect(function () { | ||
if (options && !equal(options, previousOptions.current)) { | ||
previousOptions.current = options; | ||
context.updateView(Object.assign(Object.assign({}, options), { animated: false })); | ||
} | ||
}, [context, options]); | ||
return context; | ||
} | ||
@@ -693,3 +702,3 @@ | ||
})({}, CapacitorNativeNavigation, React, ReactDOM); | ||
})({}, CapacitorNativeNavigation, React, equal, ReactDOM); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@cactuslab/native-navigation-react", | ||
"version": "4.1.0", | ||
"version": "5.0.0", | ||
"description": "React support for Native navigation for Capacitor apps", | ||
@@ -38,3 +38,3 @@ "main": "dist/plugin.cjs.js", | ||
"devDependencies": { | ||
"@cactuslab/native-navigation": "^0.4.1", | ||
"@cactuslab/native-navigation": "^0.5.0", | ||
"@capacitor/core": "^5.0.3", | ||
@@ -48,3 +48,3 @@ "@types/react": "^18.2.6", | ||
"peerDependencies": { | ||
"@cactuslab/native-navigation": "^0.4.1", | ||
"@cactuslab/native-navigation": "^0.5.0", | ||
"@capacitor/core": "^5.0.3", | ||
@@ -54,2 +54,5 @@ "react": "^18.2.0", | ||
}, | ||
"dependencies": { | ||
"fast-deep-equal": "^3.1.3" | ||
}, | ||
"scripts": { | ||
@@ -56,0 +59,0 @@ "prettier": "prettier \"**/*.{css,html,ts,js,java}\"", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
246462
2260
5
+ Addedfast-deep-equal@^3.1.3
+ Added@cactuslab/native-navigation@0.5.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
- Removed@cactuslab/native-navigation@0.4.1(transitive)