fix(miniapp-runtime): enter same page twice then exit should not throw error#7104
Merged
XGHeaven merged 1 commit intorelease/nextfrom Jun 4, 2025
Merged
fix(miniapp-runtime): enter same page twice then exit should not throw error#7104XGHeaven merged 1 commit intorelease/nextfrom
XGHeaven merged 1 commit intorelease/nextfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an error when entering the same miniapp page twice and then exiting by ensuring each page has a unique id and guarding against null lifecycle events.
- Updated unique id generation in common.ts by appending a timestamp to guarantee uniqueness.
- Refactored hooks.ts to use React's useRef for consistent page instance management during lifecycle events.
- Added a changeset entry to document the patch.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/miniapp-runtime/src/dsl/common.ts | Appended a timestamp to options for generating a unique page id. |
| packages/miniapp-runtime/src/app/hooks.ts | Refactored instance retrieval using a useRef to better manage page lifecycle events. |
| .changeset/six-zebras-sniff.md | Added changeset metadata to record the patch. |
Comments suppressed due to low confidence (2)
packages/miniapp-runtime/src/dsl/common.ts:133
- [nitpick] Consider adding a comment to explain the purpose of introducing '$iceTimestamp' to assist future maintainers and update any related tests if needed.
const uniqueOptions = Object.assign({}, options, { $iceTimestamp: Date.now() });
packages/miniapp-runtime/src/app/hooks.ts:22
- [nitpick] Adding a brief comment on the use of 'instRef' for storing the page instance can improve clarity during cleanup in the lifecycle hook.
let inst = instRef.current = getPageInstance(id);
ClarkXia
approved these changes
Jun 4, 2025
ChrisCindy
approved these changes
Jun 4, 2025
ClarkXia
added a commit
that referenced
this pull request
Jun 24, 2025
* fix: jsxplugs transform (#7076) * fix: jsxplugs transform * chore: change set * Feat: add support for custom loaders in rspack configuration (#7078) * feat: add support for custom loaders in rspack configuration * chore: changeset * fix: miniapp using absolute path to match route manifest (#7095) * fix(miniapp-runtime): enter same page twice then exit should not throw error (#7104) * fix: rename dropLog to dropLogLevel in config.md (#7103) * chore: update @swc/helpers to 0.5.17 (#7106) * Fix/provide (#7097) * feat: parse inject file * feat: compileIncludes * chore: change set * feat: getexportsvariable * chore: update versions (#7077) --------- Co-authored-by: Homyee King <HomyeeKing@gmail.com> Co-authored-by: XGHeaven <xgheaven@gmail.com> Co-authored-by: Frank <405267330@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
小程序先进入同一个页面两次,然后退出,此时触发生命周期事件会报错。
主要由两个原因: