You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, is there a way to differ the first render of the InPortal until the first outPortal is rendered? I want to prevent useless render / enable lazy loading for scenarios where the OutPortal would not be used in the user's navigation.
The text was updated successfully, but these errors were encountered:
There's no built-in support for this, but I think you can probably do it yourself. Something like:
constportalNode=React.useMemo(()=>portals.createHtmlPortalNode(),[]);return<div><portals.InPortalnode={portalNode}><MyComponentrender={false}/></portals.InPortal>{/* ... The rest of your UI ... */}<portals.OutPortalnode={props.portalNode}render={true}/></div>;
Then if MyComponent receives a render prop set to false, it does nothing. That's the basic version, but you can do anything you like with this - e.g. you can pull the render flag out into a wrapper component, and optionally render the inner component there, to avoid constructing the component at all.
Does that work for you? If there's a case that can't be solved using a simple wrapper yourself, I'm open to changes here, but it's likely to be more flexible & much simpler if you compose this on top of react-reverse-portal in your own code instead.
Hello, is there a way to differ the first render of the InPortal until the first outPortal is rendered? I want to prevent useless render / enable lazy loading for scenarios where the OutPortal would not be used in the user's navigation.
The text was updated successfully, but these errors were encountered: