react hook for dropbox file chooser
npm install use-dropbox-chooser

react hook for dropbox file chooser
with yarn:
``bash`
yarn add use-dropbox-chooser
with npm:
`bash`
npm i use-dropbox-chooser
`typescript jsx
import { useDropboxChooser } from 'use-dropbox-chooser'
function YourComponent() {
const { open, isOpen } = useDropboxChooser({
appKey: 'YOUR_DROPBOX_APP_KEY',
chooserOptions: { multiple: true, linkType: 'direct' },
onSelected: files => {
console.log(files)
},
})
return (
)
}
`
OR:
`typescript jsx
import { useDropboxChooser } from 'use-dropbox-chooser'
function YourComponent() {
const { open, isOpen } = useDropboxChooser({
appKey: 'YOUR_DROPBOX_APP_KEY',
chooserOptions: { multiple: true, linkType: 'direct' },
})
return (
onClick={async () => {
try {
const files = await open()
console.log(files)
} catch (e) {
// if closed: e === undefined
}
}}
disabled={isOpen}
>
Choose from Dropbox
)
}
`
You can also use DropboxAppProvider to avoid passing appKey on each usage:
`typescript jsx
// App.tsx
import { DropboxAppProvider } from 'use-dropbox-chooser'
function App() {
return (
)
}
// YourComponent.tsx
import { useDropboxChooser } from 'use-dropbox-chooser'
function YourComponent() {
const { open, isOpen } = useDropboxChooser({
// no need for appKey.
chooserOptions: { multiple: true, linkType: 'direct' },
})
// ... similar to other examples
}
``