Skip to content

Commit

Permalink
Merge pull request #821 from JIIOryo/fix/file-reader-id
Browse files Browse the repository at this point in the history
Fixed a bug that caused different fileReader to be selected
  • Loading branch information
nonoakij authored Apr 2, 2024
2 parents 239430d + 125e009 commit 92dd3b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/rich-beers-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@viron/app": patch
---

Fixed to randomly generate fileReader id to avoid duplication.
2 changes: 1 addition & 1 deletion packages/app/src/components/fileReader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type Props = {
} & Pick<React.InputHTMLAttributes<HTMLInputElement>, 'accept'>;
const _FileReader: React.FC<Props> = ({ accept, onChange }) => {
const id = useMemo(() => {
return `fileReader-${Date.now()}`;
return `fileReader-${Math.random()}`;
}, []);

const [file, setFile] = useState<File | null>(null);
Expand Down

0 comments on commit 92dd3b4

Please sign in to comment.