ft-widget-test
v1.0.4
Published
A simple JavaScript widget that displays a greeting message.
Downloads
38
Readme
My Widget
A simple JavaScript widget that displays a greeting message.
Installation
Install via npm:
npm install my-widget
Usage
in javascrip
import MyWidget from 'my-widget';
const widget = new MyWidget({ message: 'Hello, Universe!' });
widget.render('#my-container');
## Installation
const MyReactComponent = () => {
useEffect(() => {
// Initialize the widget
const widget = new MyWidget({ message: 'Hello from React!' });
// Render the widget inside a specific container
widget.render('#widget-container');
// Cleanup when component unmounts
return () => {
const container = document.getElementById('widget-container');
if (container && container.firstChild) {
container.removeChild(container.firstChild);
}
};
}, []);
return (
<div>
<h1>My React App</h1>
{/* Container for the widget */}
<div id="widget-container"></div>
</div>
);
};