Last active
July 17, 2025 11:13
-
-
Save NisugaJ/1078b809bfa67597a1a981350f666f11 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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