Closed heyqbnk closed 1 month ago
Latest commit: 32eacc630944a412b43c1fd08aa70655f0e2da7a
The changes in this PR will be included in the next version bump.
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
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
docs | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Oct 17, 2024 9:14am |
As we have discovered, the
miniApp.mount()
method behaves improperly becausemount
does not check if all Mini App methods are supported by the current environment.To resolve this issue, we used the following code:
This should work as expected.
⚠️ BREAKING CHANGES
This Pull Request introduces stricter SDK usage requirements.
init.postEvent: 'non-strict'
RemovedWe realized that many developers might be using the SDK without knowing that some functionality they're using may not work. This is due to the non-strict
postEvent
function in theinit
function:Using the non-strict
postEvent
can lead to bugs that developers are unaware of. For example:In this case, if the
show
method is unsupported, and thepostEvent
function is non-strict (not throwing an error, only usingconsole.warn
), the user could get stuck on the current screen without any indication to the developer.To prevent such scenarios, we now disallow non-strict
postEvent
. Only a custompostEvent
function can be passed. This way, you can bypass the protection mechanism, but you'll be fully aware of the risks. This function can also be used to decorate the originalpostEvent
from the SDK.Require
isMounted
andisSupported
ChecksSince we no longer allow non-strict actions, most component and utility methods now include the
isSupported
property. For example:Calling the
mount
method without checking if it's supported may throw an error if the method is unsupported in the current Mini App version.Additionally, if a component has the
mount
method, many of its other methods now check if the component was mounted. If it wasn't, an error will be thrown. This behavior ensures that you are working with components within their intended lifecycle.For example, the following code will throw an error: