33. Adding an Image Preview to the Picker

03. NextJS Essentials (App Router) 34. Improving the Image Picker Component There are two improvements you could / should make to that "Image Picker" component: 1) Reset the previewed image if no image was selected: Add set setPickedImage(null); to the if (!file) block: if (!file) { setPickedImage(null); return; } 2) Add the required prop to the (hidden) element: This ensures that the can't be submitted without an image being selected.

Иконка канала BackDev
52 подписчика
12+
1 просмотр
2 месяца назад
12+
1 просмотр
2 месяца назад

03. NextJS Essentials (App Router) 34. Improving the Image Picker Component There are two improvements you could / should make to that "Image Picker" component: 1) Reset the previewed image if no image was selected: Add set setPickedImage(null); to the if (!file) block: if (!file) { setPickedImage(null); return; } 2) Add the required prop to the (hidden) element: This ensures that the can't be submitted without an image being selected.

, чтобы оставлять комментарии