Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why the key and type are copied over directly? #16

Open
NE-SmallTown opened this issue Apr 15, 2017 · 0 comments
Open

Why the key and type are copied over directly? #16

NE-SmallTown opened this issue Apr 15, 2017 · 0 comments

Comments

@NE-SmallTown
Copy link

NE-SmallTown commented Apr 15, 2017

In the doc:

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

But I check the src code:

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?

@NE-SmallTown NE-SmallTown changed the title Why key and type are the same? Why key and type are copied over directly? Apr 15, 2017
@NE-SmallTown NE-SmallTown changed the title Why key and type are copied over directly? Why the key and type are copied over directly? Apr 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant