Skip to content

Instantly share code, notes, and snippets.

@NisugaJ
Last active July 17, 2025 11:13
Show Gist options
  • Save NisugaJ/1078b809bfa67597a1a981350f666f11 to your computer and use it in GitHub Desktop.
Save NisugaJ/1078b809bfa67597a1a981350f666f11 to your computer and use it in GitHub Desktop.
import React, { useEffect } from "react";
declare global {
namespace JSX {
interface IntrinsicElements {
'enquiries-ai-widget': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
}
}
}
const WidgetComponent = () => {
useEffect(() => {
// Dynamically load the widget script
const script = document.createElement('script');
script.type = 'module';
script.src = 'https://ai-chat-app.netlify.app/enquiries-ai-widget.umd.js';
document.head.appendChild(script);
return () => {
// Cleanup: remove script when component unmounts
document.head.removeChild(script);
};
}, []);
return (
<enquiries-ai-widget></enquiries-ai-widget>
);
};
export default WidgetComponent;
// Usage example in a React app
const ClientReactApp = () => {
return (
<div>
<h1>This is the Client's React App</h1>
<WidgetComponent />
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment