{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/flux/issues/354","repository_url":"https://api.github.com/repos/facebook/flux","labels_url":"https://api.github.com/repos/facebook/flux/issues/354/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flux/issues/354/comments","events_url":"https://api.github.com/repos/facebook/flux/issues/354/events","html_url":"https://github.com/facebook/flux/pull/354","id":155144827,"number":354,"title":"Proposal: Container class inherits React Component","user":{"login":"alexeyraspopov","id":858295,"avatar_url":"https://avatars.githubusercontent.com/u/858295?v=3","gravatar_id":"","url":"https://api.github.com/users/alexeyraspopov","html_url":"https://github.com/alexeyraspopov","followers_url":"https://api.github.com/users/alexeyraspopov/followers","following_url":"https://api.github.com/users/alexeyraspopov/following{/other_user}","gists_url":"https://api.github.com/users/alexeyraspopov/gists{/gist_id}","starred_url":"https://api.github.com/users/alexeyraspopov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexeyraspopov/subscriptions","organizations_url":"https://api.github.com/users/alexeyraspopov/orgs","repos_url":"https://api.github.com/users/alexeyraspopov/repos","events_url":"https://api.github.com/users/alexeyraspopov/events{/privacy}","received_events_url":"https://api.github.com/users/alexeyraspopov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-16T23:26:21Z","updated_at":"2016-05-16T23:30:15Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/facebook/flux/pulls/354","html_url":"https://github.com/facebook/flux/pull/354","diff_url":"https://github.com/facebook/flux/pull/354.diff","patch_url":"https://github.com/facebook/flux/pull/354.patch"},"body":"After #352 I've started to think that `Container.create` becomes complicated and redundant.\r\n\r\nSince `calculateState` and `getStores` are static they don't have an access to container instance, so we need to  provide this info to them. I'm not familiar with the idea of using static methods, so probably I'm doing a bad thing. This topic has to be discussed.\r\n\r\nAnother thing is `options`. By providing `{pure: true|false}`, `{withProps: true|false}` or `{withContext: true|false}` we're specifying an API that uses React's patterns. What if we can just use these patterns.\r\n\r\nProposed implementation provides `Container` as a class that inherits `React.Component`.\r\n\r\n```javascript\r\nclass ThingsContainer extends Container {\r\n  getStores() {\r\n    return [ThingsContainer];\r\n  }\r\n\r\n  calculateState() {\r\n    return {\r\n      things: ThingsContainer.getState();\r\n    };\r\n  }\r\n\r\n  render() {\r\n    return <ThingsList things={this.state.things} />;\r\n  }\r\n}\r\n```\r\n\r\nSo, here are benefits:\r\n\r\n 1. `Container` is pure by default (as it was before). If the user needs change this behavior, they're specifying custom `shouldComponentUpdate()` (which is React's pattern) instead of API thing `{pure: false}`.\r\n 2. `getStores()` and `calculateState()` have an access to `this.props` and `this.context` so there is no need to provide additional flags like `withProps` and `withContext`.\r\n\r\n`FluxMixinLegacy` also needs the same updates, so I will do them after we consider this proposal as useful."},"comment":{"url":"https://api.github.com/repos/facebook/flux/issues/comments/219578649","html_url":"https://github.com/facebook/flux/pull/354#issuecomment-219578649","issue_url":"https://api.github.com/repos/facebook/flux/issues/354","id":219578649,"user":{"login":"alexeyraspopov","id":858295,"avatar_url":"https://avatars.githubusercontent.com/u/858295?v=3","gravatar_id":"","url":"https://api.github.com/users/alexeyraspopov","html_url":"https://github.com/alexeyraspopov","followers_url":"https://api.github.com/users/alexeyraspopov/followers","following_url":"https://api.github.com/users/alexeyraspopov/following{/other_user}","gists_url":"https://api.github.com/users/alexeyraspopov/gists{/gist_id}","starred_url":"https://api.github.com/users/alexeyraspopov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexeyraspopov/subscriptions","organizations_url":"https://api.github.com/users/alexeyraspopov/orgs","repos_url":"https://api.github.com/users/alexeyraspopov/repos","events_url":"https://api.github.com/users/alexeyraspopov/events{/privacy}","received_events_url":"https://api.github.com/users/alexeyraspopov/received_events","type":"User","site_admin":false},"created_at":"2016-05-16T23:30:15Z","updated_at":"2016-05-16T23:30:15Z","body":"The other thing that should be mentioned is prototype chain. Currently, it looks like:\r\n\r\n```\r\nPureComponent\r\n  ContainerClass\r\n    TheContainer (provided by the user)\r\n      ReactComponent\r\n```\r\n\r\nIn this PR chain looks like:\r\n\r\n```\r\nTheContainer (the one that user is creating)\r\n  FluxContainer\r\n    ReactComponent\r\n```\r\n"}}