8000 `useFileDialog` | Add reactivity to all of its props · Issue #4812 · vueuse/vueuse · GitHub
[go: up one dir, main page]

Skip to content
useFileDialog | Add reactivity to all of its props #4812
@hunterwilhelm

Description

@hunterwilhelm

Clear and concise description of the problem

Use case

watchEffect(() => {
    console.log({
  accept: props.allowedFileTypes?.join(','),
  directory: props.directory,
  multiple: !props.singleFile,})
})

const { open: openFileBrowser, onChange, reset } = useFileDialog({
  accept: props.allowedFileTypes?.join(','),  
  directory: props.directory,
  multiple: !props.singleFile,
})

When props.directory changes, and I can see it change via watchEffect, useFileDialog doesn't update.
So when I try to add it using a ref or computed, I get Type 'ComputedRef<boolean>' is not assignable to type 'boolean | undefined'.ts-plugin(2322)

Suggested solution

I'll make a PR in about by the end of the week that makes makes useFileDialog completely reactive.

Alternative

The alternative at the moment is to have separate component instances to reset the state. It works for now, but that means I lose the state for a bunch of other things too.

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0