Skip to content

Commit

Permalink
feat(@captn/react): allow unknown payload in useUnload
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelass committed May 8, 2024
1 parent fb99001 commit 0b9103e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/react/src/use-unload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useSDK } from "../use-sdk";
* @param {string} appId - A unique identifier for the application or SDK instance, used to
* configure the underlying `useSDK` hook for IPC communication.
* @param {string} action - The action type of the message to be sent on the "beforeunload" event.
* @param {string} [payload=appId] - The payload to be sent with the message. Defaults to the `appId`
* @param {unknown} [payload=appId] - The payload to be sent with the message. Defaults to the `appId`
* if no payload is provided.
*
* @example
Expand All @@ -32,8 +32,8 @@ import { useSDK } from "../use-sdk";
* operations to complete (e.g., network requests), and browsers might limit certain actions
* during this event.
*/
export function useUnload(appId: string, action: string, payload = appId) {
const { send } = useSDK<unknown, string>(appId, {});
export function useUnload(appId: string, action: string, payload: unknown = appId) {
const { send } = useSDK(appId, {});
useEffect(() => {
function beforeUnload() {
send({ action, payload });
Expand Down

0 comments on commit 0b9103e

Please sign in to comment.