Skip to content

Instantly share code, notes, and snippets.

@OlivierJM
Created October 13, 2021 22:25
Show Gist options
  • Save OlivierJM/0ee9236885878b113514b34ac6968880 to your computer and use it in GitHub Desktop.
Save OlivierJM/0ee9236885878b113514b34ac6968880 to your computer and use it in GitHub Desktop.
function onInputChange(file) {
// convert image file to base64 string
const reader = new FileReader();
reader.addEventListener(
'load',
() => {
setInputImg(reader.result);
},
false
);
if (file) {
reader.readAsDataURL(file);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment