useDynamicStyles.js

import { useEffect } from 'react';

export default function useDynamicStyles(styleText) {
  useEffect(() => {
    if (styleText) {
      const $style = document.createElement('style');
      document.head.appendChild($style);
      $style.innerHTML = styleText;
    }
  });
}