Use ReactDebugCurrentFrame.getStackAddendum() in element validator#13198
Merged
gaearon merged 1 commit intofacebook:masterfrom Jul 12, 2018
Merged
Use ReactDebugCurrentFrame.getStackAddendum() in element validator#13198gaearon merged 1 commit intofacebook:masterfrom
gaearon merged 1 commit intofacebook:masterfrom
Conversation
gaearon
commented
Jul 12, 2018
|
|
||
| let currentlyValidatingElement = (null: null | ReactElement); | ||
|
|
||
| export function setCurrentlyValidatingElement(element: null | ReactElement) { |
Collaborator
Author
There was a problem hiding this comment.
I didn't put it on the ReactDebugCurrentFrame object because I don't want it to be accessible by the renderers.
Instead of wrapping ReactDebugCurrentFrame.getStackAddendum() call into a custom wrapper inside ReactElementValidator, "teach" the main ReactDebugCurrentFrame.getStackAddendum() to take currently validating element into account.
92267b6 to
4fd8299
Compare
bvaughn
approved these changes
Jul 12, 2018
|
|
||
| if (__DEV__) { | ||
| // Component that is being worked on | ||
| // Stack implementation injected by the current renderer. |
Contributor
There was a problem hiding this comment.
This comment took me back to the stack/fiber split days 😅
| ReactDebugCurrentFrame.getStackAddendum = function(): string { | ||
| let stack = ''; | ||
|
|
||
| // Add an extra top frame while an element is being validated |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Doesn't change anything functionally, but moves the logic for tracking the currently validated element into a centralized place instead of amending the stack in an ad hoc way.
This moves us closer to making
warning()calls append the stack automatically without having to think where that call happens.