MichalZalecki / react-portal-universal

Generic wrapper for React's createPortal allowing for rendering portals on the server
ISC License
65 stars 13 forks source link

Critical: Concurrent renders #5

Open CosticaPuntaru opened 5 years ago

CosticaPuntaru commented 5 years ago

on the server side there can be more then one requests at the same time being processed,

the const portals = []; at the file level will be shared between requests, and the output won't be what is expected.

in order to work properly the portals array needs to be sandboxed per request.

MichalZalecki commented 5 years ago

@CosticaPuntaru That's a valid point, thanks. It would be better when the first call of appendUniversalPortals would create a scope limited to the single request and then inject the markup.

MioQuispe commented 5 years ago

I'm a fan of this, but perhaps add a big fat disclaimer not to use this until this issue is fixed? Only saw this by chance and it's a dealbreaker tbh.

MichalZalecki commented 5 years ago

@MioQuispe Sure, thanks.

MioQuispe commented 5 years ago

@MichalZalecki Maybe this is helpful: https://jeremygayed.com/making-head-tag-management-thread-safe-with-react-head-323654170b45 https://github.com/tizmagik/react-head

I would help you out otherwise but I'm suuuper busy atm