destroy
destroy()
destroy()Cleans up the button and closes any open payment modals.
Syntax
button.destroy()Returns
Type:
voidDescription: No return value
When to Use
Call destroy() when:
Component unmounts (React, Vue, Angular)
Page navigation occurs
Button is removed from the DOM
Application cleanup is needed
Usage
React Component Cleanup:
useEffect(() => {
const button = new ButtonDynamicPrice({
price: 99.99,
apiKey: "your_api_key"
});
buttonRef.current.appendChild(button.render());
// Cleanup function
return () => {
button.destroy(); // Remove button and close modal
};
}, []);Manual Cleanup:
const button = new ButtonDynamicPrice({
price: 49.99,
apiKey: "your_api_key"
});
document.getElementById('container').appendChild(button.render());
// Later, when removing the button
button.destroy();What destroy() Does:
Removes the button element from the DOM
Closes any open payment modals
Cleans up event listeners
Prevents memory leaks
Last updated
Was this helpful?