Description
I found this bug while working on an unrelated PR #22064. Looks like there's a missing else
, because the value
set in line 978 is always overwritten in line 980. Given that children.toString()
and children[0].toString()
will return the same string for one-element arrays, I assume the best (for perf and bundle size) fix would be to remove the assignment inside the if
block.
react/packages/react-dom/src/server/ReactDOMServerFormatConfig.js
Lines 973 to 980 in fd5e01c
Because the observable behavior is identical whether or not children
is a scalar or a one-element array, I'm not sure a test could be written to verify a fix.
EDIT: I updated the text above after I learned that Array.prototype.toString()
acts the same as Array.prototype.join()
. JavaScript teaches me something new every day!