DEV Community

Discussion on: Upload mutiple image component and get base64 format

Collapse
 
jwhenry3 profile image
Justin Henry

Great concept, just some suggestions:

  • you don't need images && images?.length. just use images?.length
  • "on" callbacks should typically be set before executing the read to avoid race conditions with the asynchronous operation. It is possible that the onload will fire before the callback is set (low chance, but could occur with tiny files)
  • you will want to avoid using main unless it is in the main layout of an application:
  • avoid using set as a prop prefix, as it gets mixed up with state housed in the component (redux,useState, etc), instead use onChange or something like that
  • form elements can be housed inside labels to avoid the need to specify a "for" attribute. this is a doable use case since your input is hidden.
Collapse
 
mohsinalisoomro profile image
MOHSIN ALI SOOMRO

Thanks 👍 for suggestions