3 ms·
I'm curious to see how mixins play out with ES6. While something similar to 'include' in Ruby would be nice, I've got a hard time seeing how that would fly with
by donw 12y ago
I'm curious to see how mixins play out with ES6. While something similar to 'include' in Ruby would be nice, I've got a hard time seeing how that would fly with multiple invocations of getInitialState, for example.
Of course, the big thing we're all waiting for is Native. If that truly offers a bridge, rather than a wrapper, to native APIs from Javascript, then it will be a game-changer.
- spicyj 12y agoMost cases of mixins (especially ones that involve state, as you allude to) can be implemented via composition by creating wrapper components instead. This is how Relay (http://facebook.github.io/react/blog/2015/02/20/introducing-relay-and-graphql.html http://facebook.github.io/react/blog/2015/02/20/introducing-...) works and makes different components more contained and easier to reason about. Here's one description of how to develop containers (really, higher-order components) from someone who works on Relay: https://github.com/ericclemmons/react-resolver/issues/8#issuecomment-77765843 https://github.com/ericclemmons/react-resolver/issues/8#issu... (We know people are excited about React Native and we're working hard to get it out the door – keep your eyes peeled!)
- acdlite 12y agoLike spicyj said, the wrapper components pattern works really well. Some people have started referring to this as a separation between "smart" and "dumb" components. For instance, "smart" components do things like fetch data, then pass the data as props to "dumb" components. It's a cleaner separation of concerns than having a single component do everything via a mixin. This is the pattern that the Flux library I wrote uses: https://github.com/acdlite/flummox/blob/master/docs/api/FluxComponent.md https://github.com/acdlite/flummox/blob/master/docs/api/Flux... I wrote also wrote a bit about why components are generally preferable to mixins: https://github.com/acdlite/flummox/blob/master/docs/why-flux-component-is-better-than-flux-mixin.md https://github.com/acdlite/flummox/blob/master/docs/why-flux...
- funkiee 12y agoI strongly feel that React Native is going to come out right around F8, but cannot prove it other than that the React team seems to be speaking there and this comment on twitter https://twitter.com/reactjs/status/573872611853123584 https://twitter.com/reactjs/status/573872611853123584 I'm getting pretty excited to start working with React Native either way.