Open jesstelford opened 5 years ago
Here's an example of using it with next.js: https://github.com/zeit/next.js/tree/canary/examples/with-portals-ssr
Do you either of you need assistance in getting this pushed through?
EDIT: oh duh, the below is exactly what you do 🤦♂
Why not use context to pass the per-render portal state around?
Wrap the app with the Context.Provider and that removes the new ServerPortal()
call.
export const PortalContext = React.createContext()
const UniversalPortalProvider = ({children, store}) => (
<PortalContext.Provider value={store}>
{children}
</PortalContext.Provider>
)
if there's a store, it means it got passed by the SSR, and the portals use it, otherwise they're on the client.
Will this PR be merged? Can I help?
@svobik7 Thank you for your interest. I don’t actively maintain this so if you want a quick fix feel free to fork it and in the meantime I try to find some time to look into that. Sine I neglected this project I’ll need a moment or two to get back on track
If you just make sure this actually solves your problem that’s great
Fixes #5, and I think #2.
Heavily inspired by
styled-components
, this PR completely changes the API, but should make things concurrent-safe:Notes:
@jesstelford/react-portal-universal
for testing out