react-id-generator icon indicating copy to clipboard operation
react-id-generator copied to clipboard

Fails for streaming rendering

Open wmertens opened this issue 6 years ago • 2 comments

The id is implemented as a module scoped var, and if 2 renders are going on simultaneously due to streaming rendering halting, they will influence each other.

The safe way to implement it is to use context.

wmertens avatar Jul 02 '19 12:07 wmertens

hey @wmertens could you create an example that demonstrates this bug?

Tomekmularczyk avatar Jul 02 '19 15:07 Tomekmularczyk

Hmmm, this is a theoretical deduction :) You connect to the server, it does SSR and sends you the page with streaming render. At the same time, someone else does the same. Since the rendering resets the id, some part of the first render will have a reset id.

Not sure if that actually influences things, maybe the streaming render first creates the entire vDOM and slurps up all the id numbers 🤔 but OTOH that's depending on an unknown implementation detail.

wmertens avatar Jul 02 '19 15:07 wmertens