{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react/issues/9035","repository_url":"https://api.github.com/repos/facebook/react","labels_url":"https://api.github.com/repos/facebook/react/issues/9035/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react/issues/9035/comments","events_url":"https://api.github.com/repos/facebook/react/issues/9035/events","html_url":"https://github.com/facebook/react/issues/9035","id":209154809,"number":9035,"title":"Doc of function component maybe needs review","user":{"login":"NE-SmallTown","id":18418010,"avatar_url":"https://avatars.githubusercontent.com/u/18418010?v=3","gravatar_id":"","url":"https://api.github.com/users/NE-SmallTown","html_url":"https://github.com/NE-SmallTown","followers_url":"https://api.github.com/users/NE-SmallTown/followers","following_url":"https://api.github.com/users/NE-SmallTown/following{/other_user}","gists_url":"https://api.github.com/users/NE-SmallTown/gists{/gist_id}","starred_url":"https://api.github.com/users/NE-SmallTown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NE-SmallTown/subscriptions","organizations_url":"https://api.github.com/users/NE-SmallTown/orgs","repos_url":"https://api.github.com/users/NE-SmallTown/repos","events_url":"https://api.github.com/users/NE-SmallTown/events{/privacy}","received_events_url":"https://api.github.com/users/NE-SmallTown/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-02-21T14:05:26Z","updated_at":"2017-02-25T01:48:34Z","closed_at":"2017-02-21T16:54:16Z","body":"In the doc of [describtion of mount](https://facebook.github.io/react/contributing/implementation-notes.html#mounting-host-elements):\r\n\r\n```\r\nfunction mount(element) {\r\n  var type = element.type;\r\n  if (typeof type === 'function') {\r\n    // User-defined components\r\n    return mountComposite(element);\r\n  } else if (typeof type === 'string') {\r\n    // Platform-specific components\r\n    return mountHost(element);\r\n  }\r\n}\r\n\r\n```\r\n\r\nIf we have a component like `function UserInfo(props) { return (<div>props.name</div>);}` and we call `<UserInfo />` somewhere,then it will call  `return mountComposite(element);`\r\n\r\nThen at `mountComposite`:\r\n\r\n```\r\n// This function only handles elements with a composite type.\r\n// For example, it handles <App /> and <Button />, but not a <div />.\r\nfunction mountComposite(element) {\r\n  var type = element.type;\r\n  var props = element.props;\r\n\r\n  var renderedElement;\r\n  if (isClass(type)) {\r\n    // Component class\r\n    var publicInstance = new type(props);\r\n    // Set the props\r\n    publicInstance.props = props;\r\n    // Call the lifecycle if necessary\r\n    if (publicInstance.componentWillMount) {\r\n      publicInstance.componentWillMount();\r\n    }\r\n    renderedElement = publicInstance.render();\r\n  } else if (typeof type === 'function') {\r\n    // Component function\r\n    renderedElement = type(props);\r\n  }\r\n\r\n  // This is recursive but we'll eventually reach the bottom of recursion when\r\n  // the element is host (e.g. <div />) rather than composite (e.g. <App />):\r\n  return mount(renderedElement);\r\n}\r\n\r\n```\r\n\r\nIt will call `renderedElement = type(props);`, and the type is our `UserInfo` function.This makes me consider that **react don't instance the function component**,it just call it and receive the returned value.But I see the src code of [ReactCompositeComponent.js](https://github.com/facebook/react/blob/869c7798611ac17634e0a4cde71b4322dce20b87/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js#L207),and it shows **react create a instance named `StatelessComponent`**.\r\n\r\nIf I am wrong,please let me know.If not,I think we can add some tips about this."},"comment":{"url":"https://api.github.com/repos/facebook/react/issues/comments/282450168","html_url":"https://github.com/facebook/react/issues/9035#issuecomment-282450168","issue_url":"https://api.github.com/repos/facebook/react/issues/9035","id":282450168,"user":{"login":"NE-SmallTown","id":18418010,"avatar_url":"https://avatars.githubusercontent.com/u/18418010?v=3","gravatar_id":"","url":"https://api.github.com/users/NE-SmallTown","html_url":"https://github.com/NE-SmallTown","followers_url":"https://api.github.com/users/NE-SmallTown/followers","following_url":"https://api.github.com/users/NE-SmallTown/following{/other_user}","gists_url":"https://api.github.com/users/NE-SmallTown/gists{/gist_id}","starred_url":"https://api.github.com/users/NE-SmallTown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NE-SmallTown/subscriptions","organizations_url":"https://api.github.com/users/NE-SmallTown/orgs","repos_url":"https://api.github.com/users/NE-SmallTown/repos","events_url":"https://api.github.com/users/NE-SmallTown/events{/privacy}","received_events_url":"https://api.github.com/users/NE-SmallTown/received_events","type":"User","site_admin":false},"created_at":"2017-02-25T01:48:34Z","updated_at":"2017-02-25T01:48:34Z","body":"@gaearon Dan,@aweary doesn't reply after he comment,I don't know if it is appropriate to send a pr.Please  let me know,thanks a lot."}}
{"actor":{"display_login":"NE-SmallTown"}}