eui icon indicating copy to clipboard operation
eui copied to clipboard

Icons not loading when page loads

Open silverview7 opened this issue 1 year ago • 3 comments

Hi all,

I've been facing an issue where for example I am using the EuiFieldText or EuiDatePicker and the icons don't load in. Instead there's a grey box in place of where the icon should be. gitelasticuiload

Not sure whether its the way I'm implementing it or if its a known issue.

silverview7 avatar Aug 03 '22 05:08 silverview7

Hi @silverview7,

It seems that is something wrong with the way you're setting up EUI. Are you following these instructions?

https://eui.elastic.co/#/guidelines/getting-started#setting-up-your-application

miukimiu avatar Aug 03 '22 12:08 miukimiu

Could also be related to #5463 if you are not using webpack to bundle your app.

thompsongl avatar Aug 04 '22 17:08 thompsongl

Using import { appendIconComponentCache } from '@elastic/eui/es/components/icon/icon'; then caching my needed icons fixed the issue

silverview7 avatar Aug 06 '22 00:08 silverview7

👋 This issue hasn't seen activity in 3 days, so we're automatically closing this issue as answered. Please leave a comment if that's not the case, or if you have any remaining questions or issues.

github-actions[bot] avatar Aug 11 '22 16:08 github-actions[bot]

I incidentally discovered today that as long as the StrictMode is not opened, EuiIcon can be loaded correctly. However, React is officially recommended that to completely follow the strict mode requirements to avoid unknown BUGs, so it is a bit uncomfortable.

I'm not used to close the StrictMode, but now I have to.

RickoNoNo3 avatar Aug 14 '22 10:08 RickoNoNo3

@RickoNoNo3 That's a great solution, and honestly better than caching all the icons individually. It's also fixed some other strange behaviors I have noticed while using this UI. Thing is StrictMode isnt used in production anyways so shouldn't be to big of a deal, as long as precautions are taken.

silverview7 avatar Aug 18 '22 01:08 silverview7

We've had an internal report of icons not loading, and I've now reproduced in a fresh create-react-app in which our icons don't load. Looks like it is related to how strict mode changes React's rendering; I have a fix that works for create-react-app and will put up a PR once we confirm it fixes our internal case as well.

chandlerprall avatar Aug 22 '22 19:08 chandlerprall