diff --git a/sample/create-react-app-5/src/Sample.tsx b/sample/create-react-app-5/src/Sample.tsx index 96af07507..6d3353fd7 100644 --- a/sample/create-react-app-5/src/Sample.tsx +++ b/sample/create-react-app-5/src/Sample.tsx @@ -43,8 +43,10 @@ export default function Sample() { function onFileChange(event: React.ChangeEvent): void { const { files } = event.target; - if (files && files[0]) { - setFile(files[0] || null); + const nextFile = files?.[0]; + + if (nextFile) { + setFile(nextFile); } } diff --git a/sample/next-app/app/Sample.tsx b/sample/next-app/app/Sample.tsx index e5f9afb39..e68abb5a1 100644 --- a/sample/next-app/app/Sample.tsx +++ b/sample/next-app/app/Sample.tsx @@ -45,8 +45,10 @@ export default function Sample() { function onFileChange(event: React.ChangeEvent): void { const { files } = event.target; - if (files && files[0]) { - setFile(files[0] || null); + const nextFile = files?.[0]; + + if (nextFile) { + setFile(nextFile); } } diff --git a/sample/next-pages/pages/Sample.tsx b/sample/next-pages/pages/Sample.tsx index 25ce12525..d27ca0dd6 100644 --- a/sample/next-pages/pages/Sample.tsx +++ b/sample/next-pages/pages/Sample.tsx @@ -41,8 +41,10 @@ export default function Sample() { function onFileChange(event: React.ChangeEvent): void { const { files } = event.target; - if (files && files[0]) { - setFile(files[0] || null); + const nextFile = files?.[0]; + + if (nextFile) { + setFile(nextFile); } } diff --git a/sample/parcel2/Sample.tsx b/sample/parcel2/Sample.tsx index b41e5b451..804597b1b 100644 --- a/sample/parcel2/Sample.tsx +++ b/sample/parcel2/Sample.tsx @@ -45,8 +45,10 @@ export default function Sample() { function onFileChange(event: React.ChangeEvent): void { const { files } = event.target; - if (files && files[0]) { - setFile(files[0] || null); + const nextFile = files?.[0]; + + if (nextFile) { + setFile(nextFile); } } diff --git a/sample/vite/Sample.tsx b/sample/vite/Sample.tsx index 96af07507..6d3353fd7 100644 --- a/sample/vite/Sample.tsx +++ b/sample/vite/Sample.tsx @@ -43,8 +43,10 @@ export default function Sample() { function onFileChange(event: React.ChangeEvent): void { const { files } = event.target; - if (files && files[0]) { - setFile(files[0] || null); + const nextFile = files?.[0]; + + if (nextFile) { + setFile(nextFile); } } diff --git a/sample/webpack5/Sample.tsx b/sample/webpack5/Sample.tsx index 96af07507..6d3353fd7 100644 --- a/sample/webpack5/Sample.tsx +++ b/sample/webpack5/Sample.tsx @@ -43,8 +43,10 @@ export default function Sample() { function onFileChange(event: React.ChangeEvent): void { const { files } = event.target; - if (files && files[0]) { - setFile(files[0] || null); + const nextFile = files?.[0]; + + if (nextFile) { + setFile(nextFile); } }