N
N
nickname133842019-12-20 13:04:40
JavaScript
nickname13384, 2019-12-20 13:04:40

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

1 answer(s)
H
hzzzzl, 2019-12-20
@nickname13384

TO DO: add listener on window resize

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question