getPortal

by passing the Portal id to `getPortal` it will return the portal component and ready to use in your plugin.

How to use

import { Plugin } from '@root'
import { useRef } from 'react'

const Application = () => {
    const myAwesomePortal = useRef(Plugin.getPortal('my-awesome-portal'))

    const handleOnImageLoaded = () => {
        console.log('Loaded')
    }

    if (myAwesomePortal.current) {
        const PortalComponent = myAwesomePortal.current

        return (
            <Wrapper>
                <PortalComponent
                    onImageLoaded={handleOnImageLoaded}
                    imageSrc={'https://s3-eu-west-1.amazonaws.com/dashboard-graphics/Dashboard-Icon.png'}
                />
            </Wrapper>
        )
    } else {
        return (
            <Wrapper>
                {'No portal found 😥'}
            </Wrapper>
        )
    }
}

export {
    Application
}

Last updated