-
Notifications
You must be signed in to change notification settings - Fork 843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EuiIcon] Early setState yields a console error #4783
Comments
Thanks, @closingin |
Thanks for raising @closingin I've just run into this issue with the same warning message and @thompsongl I can reliably reproduce this. When I use an Form Control I'm using version 34.2.0, I hope this helps. |
Thanks @jeanpauldejong! I tried to create a minimal test case in CodeSandbox but I'm not able to reproduce it. Can you provide a CodeSandbox link with the error? That'll help us resolve this issue quickest. |
Sure no worries. Here is an example. The SignInForm.tsx has only two fields EuiText with an icon for email and the EuiPassword field. The moment I disable the display of such icons the error goes away. I hope that helps. https://codesandbox.io/s/elastic-eui-euiicon-i1p56?file=/src/SignInForm.tsx |
Thanks for that! Using that, I found that the issue is exposed because of It's still something we should fix in EUI but, in the mean time, if you turn off strict mode you can avoid the error. |
I was able to reproduce in our docs by adding:
in src-docs/src/views/button/button.js , and then navigating away from and back to the buttons page. |
Anyone looking into this? I'd be happy to take it :) |
I've also been encountering this bug |
Please backport the fix for this to pre v52 (deprecation of legacy theme) |
Our backport strategy excludes this, per https://github.com/elastic/eui/blob/main/wiki/releasing-versions.md
The legacy theme was deprecated back in September (#5222), and the CSS-in-JS tentative schedule (#3912) has always included some language around deprecating/removing/breaking the legacy theme since it was created. While the setState warning is annoying (and we're likely getting back to this later in the week), to my knowledge it doesn't affect anything beyond the console log which we would not consider a backport for, either. |
@thompsongl I'm doing some quick testing on this now and I don't think @chandlerprall's repro steps in #4783 (comment) is valid. The Thoughts? |
Oh right on. Yeah cherry pick or whatever seems best. |
Hello guys!
I just noticed that there's a little bug on the
EuiIcon
component, as athis.setState
is called too early in the process, yielding the following console error :Warning: Can't call setState on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to 'this.state' directly or define a 'state = {};' class property with the desired state in the EuiIcon component.
Looking at the codebase, the problem lies in the component constructor on l.594 where
loadIconComponent
is called, triggering thesetState
on l.635I don't have much background in this library, but from what I see you're building an icon cache for every
EuiIcon
that gets spawned, to improve rendering performance of otherEuiIcon
s with the sameiconType
? If that is so, I think moving the problematic code tocomponentDidMount
would fix the problem without breaking much things.I'm sorry that I don't have the time to open a PR 😔
The text was updated successfully, but these errors were encountered: