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

Load function isn't being rerun when I navigate to the same url with different id parameter #12679

Closed
craigcosmo opened this issue Sep 17, 2024 · 2 comments

Comments

@craigcosmo
Copy link

craigcosmo commented Sep 17, 2024

Describe the bug

Load function isn't being rerun when I navigate to the same url with different id parameter

Reproduction

CleanShot 2024-09-17 at 15 48 28
folder structure

+page.server.ts

import api from '$lib/api'
import { getServer } from '$lib/getServer'

export const load = async (event: any) => {
	const token = event.locals.token
	try {
		const [product, products] = await Promise.all([
			getServer(api.getProduct + event.params.id, token),
			getServer(api.getProducts, token),
		])
		return {
			product: product,
			products: products,
		}
	} catch (error) {
		return { product: [], products: [] }
	}
}

+page.svelte , url of page is like this http://localhost:1144/products/doctor-phone

<script lang="ts">
	import { siteUrl } from '$lib/config'
	import type { ProductData } from '$lib/interface'
	import urls from '$lib/urls'
	export let data: any
	let product: ProductData = data.product
	let products: ProductData[] = data.products
</script>

<div class="pb-16 sm:pb-24 lg:pt-6">
	<div>{product.title}</div>
	{#each products as item}
		<a href={siteUrl + urls.products + item.identifier}>
			some product 1
		</a>
	{/each}
</div>
// the link hrefs look like this http://localhost:1144/products/camera-nest-2024

when I click the link(anchor tag), the browser address bar did change to the whatever url I clicked, but the load function doesn't run/rerun. therefore no new data loaded.

Logs

No response

System Info

Version: 1.92.1 (Universal)
Commit: eaa41d57266683296de7d118f574d0c2652e1fc4
Date: 2024-08-07T20:16:39.455Z
Electron: 30.1.2
ElectronBuildId: 9870757
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
OS: Darwin arm64 24.0.0

Severity

blocking all usage of SvelteKit

Additional Information

No response

@brunnerh
Copy link
Member

brunnerh commented Sep 17, 2024

I would recommend providing a proper reproduction as requested by the issue template:

A link to a repository, or a fork of https://node.new/sveltekit, that reproduces the issue. Reproductions must be short, self-contained and correct and must not contain files or code that aren't relevant to the issue — please do NOT just paste a link to your project. Explaining how to reproduce is generally not enough. It pushes the burden of creating a reproduction project onto a small set of volunteer maintainers and isn't scalable. If no reproduction is provided, the issue will be closed.A link to a repository, or a fork of https://node.new/sveltekit, that reproduces the issue. Reproductions must be short, self-contained and correct and must not contain files or code that aren't relevant to the issue — please do NOT just paste a link to your project. Explaining how to reproduce is generally not enough. It pushes the burden of creating a reproduction project onto a small set of volunteer maintainers and isn't scalable. If no reproduction is provided, the issue will be closed.

Chances are this will be closed otherwise.

Also, this.

@craigcosmo
Copy link
Author

well there is something the the reactivity of svelte

I had to do like this

$: photos

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

No branches or pull requests

2 participants