From 190103687c4f77ee147519a744d59d54c9f98ac8 Mon Sep 17 00:00:00 2001 From: sunnylqm Date: Mon, 5 Feb 2024 22:22:11 +0800 Subject: [PATCH] fix: options --- src/provider.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/provider.tsx b/src/provider.tsx index 9f3f5d4..3e1ad09 100644 --- a/src/provider.tsx +++ b/src/provider.tsx @@ -24,7 +24,7 @@ export const PushyProvider = ({ client: Pushy; children: ReactNode; }) => { - const { strategy, useAlert } = client.options; + const { options } = client; const stateListener = useRef(); const [updateInfo, setUpdateInfo] = useState(); const [lastError, setLastError] = useState(); @@ -37,11 +37,11 @@ export const PushyProvider = ({ const showAlert = useCallback( (...args: Parameters) => { - if (useAlert) { + if (options.useAlert) { Alert.alert(...args); } }, - [useAlert], + [options], ); const switchVersion = useCallback(() => { @@ -138,6 +138,7 @@ export const PushyProvider = ({ if (isFirstTime) { markSuccess(); } + const { strategy, dismissErrorAfter } = options; if (strategy === 'both' || strategy === 'onAppResume') { stateListener.current = AppState.addEventListener( 'change', @@ -152,7 +153,6 @@ export const PushyProvider = ({ checkUpdate(); } let dismissErrorTimer: ReturnType; - const { dismissErrorAfter } = client.options; if (typeof dismissErrorAfter === 'number' && dismissErrorAfter > 0) { dismissErrorTimer = setTimeout(() => { dismissError(); @@ -162,7 +162,7 @@ export const PushyProvider = ({ stateListener.current && stateListener.current.remove(); clearTimeout(dismissErrorTimer); }; - }, [checkUpdate, client.options, dismissError, markSuccess, strategy]); + }, [checkUpdate, options, dismissError, markSuccess]); return (