Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue14 and add changlog.md #20

Closed

Conversation

xiangnuans
Copy link

@xiangnuans xiangnuans commented Nov 4, 2024

issue: #14

const tonConnectUI = globalPropertiesMap?.$tonConnectUI as TonConnectUI | undefined;

if (!tonConnectUI) {
throw new Error("TonConnect is not avaliable");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throwing an exception directly within the hooks function body will interrupt the entire setup process. Consider using an error handler or logging a console error/warning to provide a notification instead.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s an excellent question! I’ve carefully reconsidered this issue and have come up with a potential solution:

return {
            tonConnectUI: null,
            setOptions: () => console.warn("TonConnect is not available"),
            error: new Error("TonConnect is not available"),
        };

demo

const {tonConnectUI, setOptions, error} = useTonConnectUI();

    if (error) {
      console.warn(error.message); // 输出警告信息
      return {}; // 或者在 UI 上显示提示
    }

@xiangnuans
Copy link
Author

Add eslint/prettier configuration to other issue, the git commit will check all of its correlations, so it will be processed here at the same time, so you need to close the issue, details can be viewed here: #23

@xiangnuans xiangnuans closed this Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants