mirror of
https://github.com/bknd-io/bknd/
synced 2026-08-02 08:06:00 +00:00
refactor(dropzone): extract DropzoneInner and unify state management with zustand (#165)
Simplified Dropzone implementation by extracting inner logic to a new component, `DropzoneInner`. Replaced local dropzone state logic with centralized state management using zustand. Adjusted API exports and props accordingly for consistency and maintainability.
This commit is contained in:
@@ -52,7 +52,7 @@ export default function UserAvatar() {
|
||||
You can also customize the rendering of the media items and its uploading by passing a react element as a child. Here is an example of a custom `Media.Dropzone` that renders an user avatar (styled using tailwind):
|
||||
|
||||
```tsx
|
||||
import { Media, useMediaDropzone } from "bknd/elements";
|
||||
import { Media, useMediaDropzone, useMediaDropzoneState } from "bknd/elements";
|
||||
|
||||
export default function CustomUserAvatar() {
|
||||
return <Media.Dropzone
|
||||
@@ -68,11 +68,10 @@ function CustomUserAvatar() {
|
||||
const {
|
||||
wrapperRef,
|
||||
inputProps,
|
||||
state: { files, isOver, isOverAccepted, showPlaceholder },
|
||||
showPlaceholder,
|
||||
actions: { openFileInput }
|
||||
} = useMediaDropzone();
|
||||
|
||||
const file = files[0];
|
||||
const { files: [ file ], isOver, isOverAccepted } = useMediaDropzoneState();
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user