ant-design / ant-design-web3

🥳 Efficient react components for building dapps easier | Connect crypto wallets and more Web3 UI components | Web3 icons | Supports Ethereum, Solana, Bitcoin, TON, Sui and others.
https://web3.ant.design
MIT License
889 stars 147 forks source link

perf(solana): Optimize rendering times when using default connectionConfig #1246

Closed gin-lsl closed 4 days ago

gin-lsl commented 5 days ago

当未提供 connectionConfig 属性值时,由于 ConnectionProvider#config 属性默认值的缘故,会导致多次渲染。最终导致重复发起获取余额的请求。

这个 PR 优化了相关逻辑,使用 useMemo 缓存了 ConnectionProvider 需要的 props 来减少渲染次数。


When the connectionConfig prop value is not provided, the default value of the ConnectionProvider#config property causes multiple renders. This eventually leads to duplicate requests for fetching the balance.

This PR optimizes the related logic by using useMemo to cache the props needed by ConnectionProvider, reducing the number of renders.

Before: image

💡 Background and solution

🔗 Related issue link

changeset-bot[bot] commented 5 days ago

🦋 Changeset detected

Latest commit: 5d8b6ab54c585604309a2280e353ebd7d11f1774

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ----------------------- | ----- | | @ant-design/web3-solana | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 5 days ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ant-design-web3 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 18, 2024 4:37am
github-actions[bot] commented 5 days ago

Preview is ready

codecov[bot] commented 5 days ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.99%. Comparing base (ff8e95f) to head (5d8b6ab). Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1246 +/- ## ======================================= Coverage 99.99% 99.99% ======================================= Files 858 858 Lines 18297 18303 +6 Branches 1593 1595 +2 ======================================= + Hits 18296 18302 +6 Misses 1 1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

thinkasany commented 4 days ago

这里需要你手动改,没有changed的地方好像给不到suggestion image

gin-lsl commented 4 days ago

这里需要你手动改

OK,有些事情耽搁了。已修改。

thinkasany commented 4 days ago

文档中 https://solana-labs.github.io/solana-web3.js/types/ConnectionConfig.html 变成 404了。 image

gin-lsl commented 4 days ago

看起来 solana 那边生成的文档有问题,丢失了一些类型。

gin-lsl commented 4 days ago

Issue has been created https://github.com/solana-labs/solana-web3.js/issues/3586

thinkasany commented 4 days ago

看起来 solana 那边生成的文档有问题,丢失了一些类型。

单独给文档加个pr好了,看看咋补救比较好。