Answer the question
In order to leave comments, you need to log in
How to compare width of parent element with child?
Do you need to use ref( )
to change the state if the width of the child elements is greater than that of the parent ? (how to do this for two child elements?)
import React from 'react';
const Component = () => {
return (
<div className="parent" style={{width: '200px'>
<p className="child1">Text 1</p>
<p className="child2">Text 2</p>
</div>
);
};
export default Component;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question