Commit 1c162583 authored by Robert Knight's avatar Robert Knight

Fix issue that caused an effect to execute after every render

The newest react-hooks ESLint plugin correctly reported an issue where
a `useLayoutEffect` hook had a dependency on a value which changed on
every render.
parent 6b442d9b
......@@ -49,7 +49,7 @@ export default function SvgIcon({
if (!iconRegistry[name]) {
throw new Error(`Icon name "${name}" is not registered`);
}
const markup = { __html: iconRegistry[name] };
const markup = iconRegistry[name];
const element = /** @type {Ref<HTMLElement>} */ (useRef());
useLayoutEffect(() => {
......@@ -75,7 +75,7 @@ export default function SvgIcon({
return (
<span
className={classnames('svg-icon', { 'svg-icon--inline': inline })}
dangerouslySetInnerHTML={markup}
dangerouslySetInnerHTML={{ __html: markup }}
ref={element}
{...spanProps}
/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment