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(client): avoid updating routeLocale #1253

Merged
merged 5 commits into from Feb 16, 2023
Merged

fix(client): avoid updating routeLocale #1253

merged 5 commits into from Feb 16, 2023

Conversation

Mister-Hope
Copy link
Member

No description provided.

watch(
() => router.currentRoute.value.path,
(newValue) => {
if (newValue !== routePath.value) {
Copy link
Member

Choose a reason for hiding this comment

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

Is the if branch necessary?

BTW, could you check if the computedWithControl from vueuse is helpful for this case?

Copy link
Member Author

Choose a reason for hiding this comment

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

Is the if branch necessary?

It's not, removed

BTW, could you check if the computedWithControl from vueuse is helpful for this case?

Tried, but seems not working, seems like the same as the original, as long as route object change, computed is triggered.

I think that using computedWithControl should be the same as

const routePath = computed(()=>  router.currentRoute.value.path)

routePath and everything depending on it will still be triggered while scrolling.

Copy link
Member

@meteorlxy meteorlxy Feb 16, 2023

Choose a reason for hiding this comment

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

I just checked the source code of computedWithControl. It's using watch inside. 🤔

How did you try it? Something like this? (Just curious and discuss, we may not introduce vueuse into client package)

const routePath = computedWithControl(
  ()=>  router.currentRoute.value.path,
  ()=>  router.currentRoute.value.path
)

@meteorlxy meteorlxy merged commit 5eb9489 into main Feb 16, 2023
29 checks passed
@meteorlxy meteorlxy deleted the perf branch February 16, 2023 02:14
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.

[Bug report] routeLocale and route.path will be triggered unexpected.
2 participants