dillon1000/react

Commit

Warn when server-rendered markup is not what we expect on the client

As @leebyron and balpert pointed out, if the markup on the server is differnet than what the client expects undefined behavior and chaos may ensue. A good fallback
is for us to just inject the client-side markup (as it is the source of truth) and warn the user in __DEV__ that something is wrong. In order to do a fast
browser-independent check of the DOM I use an adler32 checksum of the generated markup. I believe this is better than a simple innerHTML compare because different
browsers massage innerHTML differently.
Browse files
Changed paths7 files
First-parent comparison
M src/core/ReactComponent.js ModifiedM src/core/ReactMount.js ModifiedA src/core/getReactRootElementInContainer.js AddedA src/environment/ReactMarkupChecksum.js AddedM src/environment/ReactServerRendering.js ModifiedM src/environment/__tests__/ReactServerRendering-test.js ModifiedA src/utils/adler32.js Added
Patch

Files changed

Rendering syntax-highlighted changes…