react: Bug: missing `else` statement in ReactDOMServerFormatConfig.js
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.
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!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (6 by maintainers)
Commits related to this issue
- Fixed else statment for ReactDomServerFormatConfig.js (#22309) — committed to omarfarah123/react by omarfarah123 3 years ago
- Fixed else statment for ReactDomServerFormatConfig.js (#22309) — committed to omarfarah123/react by omarfarah123 3 years ago
This issue hasn’t been assigned to anyone so I think anyone is free to open PR for it @amensum