Skip to content

Commit

Permalink
update the example with array method
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtatranta committed Nov 26, 2024
1 parent 9d0c1f8 commit 9cedb47
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ function FilePickerComponent({
<input
type="file"
onChange={Maybe.asInput((event: ChangeEvent<HTMLInputElement>) =>
Maybe.of(event.target.files?.[0]).map(doSomethingWithTheFile)
Maybe.fromFirst(Array.from(event.target.files ?? [])).map(
doSomethingWithTheFile
)
)}
/>
);
Expand Down
4 changes: 3 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ function FilePickerComponent({
<input
type="file"
onChange={Maybe.asInput((event: ChangeEvent<HTMLInputElement>) =>
Maybe.of(event.target.files?.[0]).map(doSomethingWithTheFile)
Maybe.fromFirst(Array.from(event.target.files ?? [])).map(
doSomethingWithTheFile
)
)}
/>
);
Expand Down

0 comments on commit 9cedb47

Please sign in to comment.