Skip to content

Commit

Permalink
fix review
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Feb 14, 2023
1 parent 0331379 commit b963d94
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions ee/packages/ui-theming/src/hooks/useCreateStyleContainer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { useMemo } from 'react';

export const useCreateStyleContainer = (id: string) => {
const refElement = document.getElementById('css-theme') || document.head.lastChild;
const styleElement = document.createElement('style');
styleElement.setAttribute('id', id);
document.head.insertBefore(styleElement, refElement);
return document.getElementById(id) || document.head.appendChild(document.createElement('style'));
return useMemo(() => {
const refElement = document.getElementById('css-theme') || document.head.lastChild;
const styleElement = document.createElement('style');
styleElement.setAttribute('id', id);
document.head.insertBefore(styleElement, refElement);
return document.getElementById(id) || document.head.appendChild(document.createElement('style'));
}, [id]);
};

0 comments on commit b963d94

Please sign in to comment.