overflow icon indicating copy to clipboard operation
overflow copied to clipboard

calling setState inside renderRest function throws warning

Open DavidTawil opened this issue 2 years ago • 6 comments

I'm trying to call setState inside the function that deals renderRest, in order to use those overflow elements inside a popup element. But when calling the setState to keep those items for next render, I'm getting a warning in the console: image

DavidTawil avatar Jun 06 '22 07:06 DavidTawil

I am facing same issue. I am rendering AntD Select in mode="multiple". My JSX looks like following:

<Popover>
    <Form>
        <Form.Item>
            <Select mode="multiple" />
        </Form.Item>
    </Form>
</Popover>

I click on a button which fires "onFinish" of form and I close the popover by changing its state. And I get this warning that the state(not my popover state) was set after component unmount. After going through my code for any useEffect or setState mistake. I can confirm that this is happening in <Select mode="multi" /> code. This error is not coming for single Select mode. Drilling in error log it indicates the error is coming from Overflow Component. Attaching screenshot.

Screenshot 2023-06-08 at 2 28 06 AM Screenshot 2023-06-08 at 2 29 18 AM

LohitakshTrehan avatar Jun 07 '23 20:06 LohitakshTrehan

Screenshot 2023-06-08 at 2 28 06 AM Screenshot 2023-06-08 at 2 29 18 AM

LohitakshTrehan avatar Jun 07 '23 21:06 LohitakshTrehan

@afc163 @zombieJ ^

LohitakshTrehan avatar Jun 07 '23 21:06 LohitakshTrehan

I am seeing this error everywhere after updating to latest version of ant design :( would love some guidance

jlissner avatar Aug 03 '23 17:08 jlissner

Any news regarding this issue? There seems to be even a fix in https://github.com/react-component/overflow/pull/37

PavelGavlik avatar Aug 31 '23 14:08 PavelGavlik

Same here. I met this when using multiple Select in [email protected].

update: After edit the node_modules/rc-overflow/lib/hooks/useEffectState.js with PR#37 as @PavelGavlik mentioned, the error disappears.

the AbortController like #39 works in my scenario also(roughly), but I still have no solution without injection. Any solution for consumers so far?

chienweiluo avatar Sep 14 '23 09:09 chienweiluo