Skip to content

Commit

Permalink
feat(react): create useBridgeLoose when createLinkBridgeProvider (gro…
Browse files Browse the repository at this point in the history
  • Loading branch information
gronxb authored Mar 24, 2024
1 parent 1c36dcf commit 4f86b45
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions packages/react/src/createLinkBridgeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,30 @@ export const createLinkBridgeProvider = <
throw new Error(`useBridgeStatus must be used within a BridgeProvider`);
}

const { isNativeMethodAvailable, isWebViewBridgeAvailable, loose } =
const { isNativeMethodAvailable, isWebViewBridgeAvailable } =
bridgeStoreContext;
return {
isNativeMethodAvailable,
isWebViewBridgeAvailable,
loose,
};
};

return { bridge, BridgeProvider, useBridgeStore, useBridgeStatus };
const useBridgeLoose = () => {
const bridgeStoreContext = useContext(BridgeContext);

if (!bridgeStoreContext) {
throw new Error(`useBridgeLoose must be used within a BridgeProvider`);
}

const { loose } = bridgeStoreContext;
return { loose };
};

return {
bridge,
BridgeProvider,
useBridgeStore,
useBridgeStatus,
useBridgeLoose,
};
};

0 comments on commit 4f86b45

Please sign in to comment.