From 32952db2f8f2cf4feeb15159d94be9ce00e1fd26 Mon Sep 17 00:00:00 2001 From: Razzwan Date: Mon, 13 Nov 2023 14:46:51 +0300 Subject: [PATCH] fix(useInitData): fix data usage from outside TWA --- package.json | 2 +- src/useInitData.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 9e718c7..be957c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@altiore/twa", - "version": "1.2.4", + "version": "1.2.5", "description": "React components for Telegram WebApp", "source": "./src/index.ts", "type": "module", diff --git a/src/useInitData.ts b/src/useInitData.ts index 04e6ab2..3afd151 100644 --- a/src/useInitData.ts +++ b/src/useInitData.ts @@ -56,10 +56,10 @@ export type InitDataUnsafe = { * ``` * @group Hooks */ -const useInitData = (): { initUnsafe: InitDataUnsafe; init: InitData } => { +const useInitData = (): { initUnsafe?: InitDataUnsafe; init?: InitData } => { const WebApp = useWebApp(); - return { initUnsafe: WebApp!.initDataUnsafe, init: WebApp!.initData }; + return { initUnsafe: WebApp?.initDataUnsafe, init: WebApp?.initData }; }; export default useInitData;