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

[1st Attempt] Fix route components remounting rather than being updated when props change #439

Closed
wants to merge 3 commits into from

Conversation

pleek91
Copy link
Contributor

@pleek91 pleek91 commented Jan 24, 2025

Description

When a route's props are updated the components should not be unmounted and recreated. This fixes an issue with how route components and props were combined that was causing new components to get mounted whenever the props changed.

Note
In its current state this PR changes how the default slot of RouterView works. Which I'm hoping can be fixed so that users get the same functionality as before when using the default slot.

Copy link

netlify bot commented Jan 24, 2025

Deploy Preview for kitbag-router ready!

Name Link
🔨 Latest commit 2424fa1
🔍 Latest deploy log https://app.netlify.com/sites/kitbag-router/deploys/67941a4a75c7480007d6cc6f
😎 Deploy Preview https://deploy-preview-439--kitbag-router.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@stackoverfloweth stackoverfloweth left a comment

Choose a reason for hiding this comment

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

Seems straight forward, glad it worked out with such a relatively small change.

const SuspenseAsyncComponentPropsWrapper = defineComponent(async (input: { component: Component, props: unknown }) => {
const values = ref()

values.value = await input.props
Copy link
Contributor

Choose a reason for hiding this comment

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

So the suspense version is different because it uses top-level await for props, right?

And we only use this version when we know that the current instance has a Vue Suspense component above?

@pleek91 pleek91 changed the title Fix route components remounting rather than being updated when props change [1st Attempt] Fix route components remounting rather than being updated when props change Jan 25, 2025
@pleek91 pleek91 closed this Jan 26, 2025
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