Skip to content

Commit

Permalink
fix(ui-react): set current modal state on first call of use effect in…
Browse files Browse the repository at this point in the history
… useTonConnectModal
  • Loading branch information
thekiba committed Apr 21, 2024
1 parent 3f2954a commit a881c7f
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions packages/ui-react/src/hooks/useTonConnectModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,16 @@ export function useTonConnectModal(): Omit<WalletsModal, 'onStateChange'> {

useEffect(() => {
if (tonConnectUI) {
setState(tonConnectUI.modal.state);
return tonConnectUI.onModalStateChange((value: WalletsModalState) => {
setState(value);
});
}
}, [tonConnectUI]);

return {
state,
open: () => {
if (tonConnectUI) {
return tonConnectUI.modal.open();
}
},
close: () => {
if (tonConnectUI) {
tonConnectUI.modal.close();
}
}
state: state,
open: () => tonConnectUI?.modal.open(),
close: () => tonConnectUI?.modal.close()
};
}

0 comments on commit a881c7f

Please sign in to comment.