-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Nested Dynamic Route change causes parent route to re-render #1408
Comments
Curiously, with
The outer/root view (
…do not cause the outer view to re-render. The Is this as-designed? Is there a way to specify that query string parameters affect a route and should cause a re-render? |
I think this issue is related to #1761 . https://github.com/nuxt/nuxt.js/blob/dev/lib/app/client.js#L359 I'm not sure why fixPrepatch() is needed. I've removed following line and confirmed this change provide expected behavior for me. |
@Atinux Thank your for creating great useful framework. If you have a time, could you tell me what situation needs fixPrepatch(). |
i have the same problem, how to solve it? |
Actually, fixPrepatch is there to merge the result of |
Hi @Atinux, |
Hi @Atinux, Do you think this patch is worth to PR?
export function getRouteRecordWithParamNames (route) {
return route.matched.map(m => {
let paramNames = m.path.match(new RegExp(':[^\\/]+$', 'g'))
let paramName = null
if (paramNames !== null && paramNames.length > 0) {
paramName = paramNames[paramNames.length - 1].substring(1)
}
return {
routeRecord: m,
paramName: paramName
}
})
}
export function getChangedComponentsInstances (to, from) {
let t = getRouteRecordWithParamNames(to)
let r = []
let parentChange = false
for (var i = 0; i < t.length; i++ ) {
var paramName = t[i].paramName
var instances = t[i].routeRecord.instances
instances = Object.keys(instances).map(function (key) {
return instances[key]
})
if (parentChange) {
r = [].concat(r, instances)
} else if (paramName !== null) {
if (to.params[paramName] !== from.params[paramName]) {
parentChange = true
r = [].concat(r, instances)
}
}
}
return r
} |
PR merged |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
First off, huge thanks for Nuxt. I love it!
I have a project with a simple folder structure similar to the following:
I have included a
<nuxt-child/>
insideitems.vue
along with a list of items that link to different id's._id.vue
simply renders a modal that displays info based on the id passed as a param.This is all working and rendering properly except that each time an item is clicked, the
items.vue
component re-renders causing it reset its state and lose the users scroll position.Is this expected behavior? Is it possible to have dynamic nested routes without re-rendering their parent with each route change?
The text was updated successfully, but these errors were encountered: