diff --git a/src/components/icon/icon.tsx b/src/components/icon/icon.tsx index 090e80d76cb..ac4d8e1a5ce 100644 --- a/src/components/icon/icon.tsx +++ b/src/components/icon/icon.tsx @@ -588,23 +588,31 @@ export class EuiIcon extends PureComponent { const { type } = props; const initialIcon = getInitialIcon(type); - let isLoading = false; - - if (isEuiIconType(type) && initialIcon == null) { - isLoading = true; - this.loadIconComponent(type); - } else { - this.onIconLoad(); - } this.state = { icon: initialIcon, iconTitle: undefined, - isLoading, - neededLoading: isLoading, + isLoading: false, + neededLoading: false, }; } + componentDidMount() { + const { type } = this.props; + + if (isEuiIconType(type) && this.state.icon == null) { + //eslint-disable-next-line react/no-did-mount-set-state + this.setState({ + neededLoading: true, + isLoading: true, + }); + + this.loadIconComponent(type); + } else { + this.onIconLoad(); + } + } + componentDidUpdate(prevProps: EuiIconProps) { const { type } = this.props; if (type !== prevProps.type) { diff --git a/upcoming_changelogs/5899.md b/upcoming_changelogs/5899.md new file mode 100644 index 00000000000..ffcc7eb2560 --- /dev/null +++ b/upcoming_changelogs/5899.md @@ -0,0 +1,3 @@ +**Bug fixes** + +- Fixed `EuiIcon` from producing console warning in `React.StrictMode`