Skip to content

Make +data and +onBeforeRender cumulative #1833

Open
@brillout

Description

Note

With other frameworks, when navigating a nested layout, the outer layout isn't re-rendered and its data isn't re-fetched. Currently, with Vike, the outer layout is re-rendered, and the data() hook of the page is executed again.

Proposed solution: #1689 (comment). If you need this, add comment down below.

In the meantime, you can use +onBeforeRender as a workaround:

# Data shared across all setting pages
pages/settings/+onBeforeRender.js
pages/settings/+Layout.js

# Data only used by one page
pages/settings/privacy/+data.js
pages/settings/privacy/+Page.js

Note

Alternatively, you can use Vike extensions, such as vike-react-query, to fetch data on a component-level (thus on a layout-level as well), see https://vike.dev/data-fetching#tools.

Note

Regardless of this feature request, the plan is to stick to re-rendering the outer layout. I believe it's a less error-prone approach for the user as well as the website visitor. In practice, only the virtual DOM is "re-rendered", so the state of the outer layout is preserved and the real DOM doesn't change.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions