acdlite / acdlite/react-fiber-architecture

Why the key and type are copied over directly?

Open
#16 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
13k
Forks
763
PR merge metrics
No merged PRs in 30d

Description

In the [doc](https://github.com/acdlite/react-fiber-architecture/blob/master/README.md#type-and-key):

> In fact, when a fiber is created from an element, these two fields are copied over directly.

But I check the [src code](https://github.com/facebook/react/blob/master/src/renderers/shared/fiber/ReactFiber.js#L185):

```
var createFiber = function(tag: TypeOfWork, key: null | string): Fiber {
var fiber: Fiber = {
// Instance

tag: tag,

key: key,

type: null,

....
}
}
```

So,`key` is from the caller which means it can be `null` or not,just decided by the caller,but `type` is `null`.So,I think "these two fields are copied over directly" is not correct.

And BTW,I know what the `type` is from the src code's description and react-devtools.But I am not sure what the `key` means.Does it is what we see in the react-devtools just like `type`?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.