Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix Flow errors
  • Loading branch information
yungsters committed May 30, 2024
commit 2897d38edc367182b3d0a7bcf08e4acacb67558a
3 changes: 2 additions & 1 deletion packages/react/src/ReactChildren.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ function mapIntoArray(
if (__DEV__) {
// If `child` was an element without a `key`, we need to validate if
// it should have had a `key`, before assigning one to `mappedChild`.
if (nameSoFar !== '' && isValidElement(child) && child.key == null) {
// $FlowFixMe[incompatible-type] Flow incorrectly thinks React.Portal doesn't have a key
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is weird that React.Children doesn't operate on portals. They don't get assigned keys.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I copied this from the $FlowFixMe comments in the lines above. 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know but I found it interesting that 1) we didn't refine the type above 2) that we're checking isValidElement at all.

if (nameSoFar !== '' && child != null && isValidElement(child) && child.key == null) {
// We check truthiness of `child._store.validated` instead of being
// inequal to `1` to provide a bit of backward compatibility for any
// libraries (like `fbt`) which may be hacking this property.
Expand Down