import { useState } from 'react' import MagicPortal from 'react-magic-portal' import PortalContent from './components/portal-content' import './App.css' function App() { const [showAnchor, setShowAnchor] = useState(true) const handleMount = (anchor: Element, container: Element) => { console.log('Portal mounted:', { anchor, container }) } const handleUnmount = (anchor: Element, container: Element) => { console.log('Portal unmounted:', { anchor, container }) } return (
💡 Key Feature: Notice how MagicPortal automatically detects when the target anchor appears or disappears. When you toggle the anchor visibility, the portal content automatically mounts and unmounts without any manual intervention.
Open the browser console to see mount/unmount events. Try toggling the target anchor visibility to see how MagicPortal responds to DOM changes in real-time.