Fix concatenation of null to a warning message #13166
Merged
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.
Thanks to the renaming in #13165, I noticed a bunch of cases where we could accidentally concatenate
null
to a warning message if the stack was missing.I changed
getCurrentFiberStackInDevOrNull
to always return a string, and renamed it togetCurrentFiberStackInDev
. This fixed existing callsites that already relied on it being a string (which wasn't always the case). Then I removed a few|| ''
that now became unnecessary.I also changed the "isomorphic" type of
ReactDebugCurrentFrame.getStackAddendum()
to be tighter since we know both SSR and Fiber implementation return a string now. This is a bit optimistic because in practiceReactDebugCurrentFrame
could be from an old React version that didn't have the|| ''
isomorphic fallback, and itsgetStackAddendum
could be pointing to another renderer that has a version before this change (e.g. maybe something like React 16.4 + React DOM 16.5 + ReactDOMServer 16.4). In that case you could potentially see thenull
bug in the warning message. I don't think this matters because (a) we recommend to keep versions in sync, (b) we already have this bug in a bunch of places, and I'd prefer tightening it up now than worrying about what happens in an edge case where you mix past and present versions.