This commit is contained in:
Alexander Jordan 2026-07-14 23:29:59 -07:00 committed by GitHub
commit 6bd4e12350
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 8 deletions

View file

@ -0,0 +1,5 @@
---
"@uppy/svelte": patch
---
Fix only capturing the initial value of `uppy` in `UppyContextProvider`

View file

@ -14,12 +14,18 @@ export type { UppyContext } from "@uppy/components";
let { uppy, children } = $props()
// Create a single reactive context object
const contextValue: UppyContext = $state({
uppy,
status: 'init' as UploadStatus,
progress: 0,
})
// Create reactive state for properties of the context
let status = $state('init' as UploadStatus)
let progress = $state(0)
// Create a single context object, with some reactive properties
const contextValue: UppyContext = {
get uppy() { return uppy },
get status() { return status },
set status(value) { status = value },
get progress() { return progress },
set progress(value) { progress = value },
}
onMount(() => {
if (!uppy) {
@ -29,10 +35,10 @@ export type { UppyContext } from "@uppy/components";
const uppyEventAdapter = createUppyEventAdapter({
uppy,
onStatusChange: (newStatus: UploadStatus) => {
contextValue.status = newStatus
status = newStatus
},
onProgressChange: (newProgress: number) => {
contextValue.progress = newProgress
progress = newProgress
},
})