-
Notifications
You must be signed in to change notification settings - Fork 50.4k
Description
Do you want to request a feature or report a bug?
Feature
What is the current behavior?
Currently, if checksum mismatch happens when mounting React tree on server rendered markup, we can only get markup difference in dev environment. Reality is, mismatches happen more in production env, where there are much bigger variety of user contexts that can trigger the mismatch. It is very hard to reproduce the mismatch scenarios in dev environment, without knowing where the markup difference is.
What is the expected behavior?
What I'm proposing is to provide apps a way to obtain the markup difference even in production environment, so that the diffs can be reported back to developers for debugging mismatch root cause.
Fiber would probably change how checksum works. But before it is ready, we still need ability to debug this issue in production env.
I was trying something like this: lingyan/react@master...reportMarkupDiff It works but probably is not the best approach. The idea is simple though:
- provide a way for application to control which react tree to report markup diff upon checksum mismatch, as application might only care about mismatch in a subset of the React trees mounted and there would be concerns with markup normalization cost:
- I am using a data attribute on container node, but it is not the best approach, since container can also be document node.
- I thought about two alternative ways but neither of them is perfect:
- add
reportMarkupDiffoption toReactDom.render()signature - add a prop like
reportMarkupDiffto the element being rendered
- add
- allow application to collect the markup diff even in production environment:
- I'm setting the markup difference as the value of the same data attribute on the container node
Please share your thoughts and ideas. I am up for raising a PR to implement the most ideal approach. Thanks!