https://react.dev/learn#displaying-data
const user = {
name: 'Hedy Lamarr',
imageUrl: 'https://i.imgur.com/yXOvdOSs.jpg',
imageSize: 90,
};
export default function Profile() {
return (
<>
<h1>{user.name}</h1>
<img
className="avatar"
src={user.imageUrl}
alt={'Photo of ' + user.name}
style={{
width: user.imageSize, // Here...
height: user.imageSize // ...and here.
}}
/>
</>
);
}
How does React know that user.imageSize
, which is a number, has the pixels as a unit? How does it know that it is not, for example, %
or cm
?