reactjsreact-resize-observer

Warning: Find more than one child node with `children` in ResizeObserver. Will only observe first one


Like the description of title.In my react application has the Warning.

System: Mac OS Big Sur 11.2

Enviroment: Chrome 89.0.4389.90(正式版本) (x86_64)

The warning detail


Solution

  • I suspect this is the same problem I had with Ant Design <Affix /> Component.

    Basically, your Affix Component (probably) has multiple children as below:

    <Affix>
        <div>...1</div>
        <div>...2</div>
    </Affix>
    

    It should only have one child - a little like React JSX should only have one root component returned.

    So the above can become:

    <Affix>
        <div>
            <div>...1</div>
            <div>...2</div>
        </div>
    </Affix>