JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<div id="app"></div>
CSS
.image {
margin: 5px;
padding: 5px;
border: 1px solid silver;
}
Babel + JSX
function Image({ src }) {
const [ sizes, setSizes ] = React.useState({});
return (
<div className="image">
<img
src={src}
onLoad={({ target: { width, height } }) => setSizes({ width, height })}
/>
<pre>{JSON.stringify(sizes, null, 2)}</pre>
</div>
);
}
ReactDOM.render(
<div>
{[
{ src: 'https://cdn.cnn.com/cnnnext/dam/assets/170821152317-donald-trump-squint-point-eclipse-large-169.jpg' },
{ src: 'https://media11.s-nbcnews.com/j/MSNBC/Components/Video/201912/f_mo_la_trump_dingell.focal-760x428.jpg' },
{ src: 'https://img.particlenews.com/image.php?type=thumbnail_1024x576&url=1hzTy7_0NnObNnD00' },
].map(n => <Image {...n} />)}
</div>,
document.getElementById('app')
);