How to set the height and width using the percent value?
vieyama opened this issue · 1 comments
vieyama commented
How to set the height and width using the percent value?
bmestanov commented
Hey, check out this library react-container-dimensions
.
import ContainerDimensions from 'react-container-dimensions';
// for example set to 50%
<ContainerDimensions>
{({ width, height }) => (
<Image
src={YOUR_URL}
height={height * 0.5}
width={width * 0.5}
/>
)}
</ContainerDimensions>
Cheers