React v0.11
facebook.github.io
facebook.github.io
Wish I'd talked to the guys at FB about it more before I left.
It's something i've been struggling with quite a bit. Conceptually i love Polymer, and really want to switch, but React's serverside rendering is just hard to beat. I'm scared of showing users page load spinners while my 20 Polymer components all load their data heh
Polymer is sort of React Components "To the extreme" (to me). They represent everything i love about React Components, with encapsulated JS, CSS, and HTML. Meaning that i can pull in someone elses Polymer component, or use one from another project, and it "just works".
Granted, the HTTP spam scares the hell out of me. Vulcanize may help with that, but i have yet to really figure out the whole process for my workflows.
Having to load an html wrapper, do clientside routing, load the data into the clientside templates and render templates all for the first page load just scares me with Polymer. React solves this by letting me do it all serverside, and it is wonderful at that.
I really do love React. I'll likely stick with React for another project or two, unless i conceptually have an "ah hah" moment with Polymer.. but until i can render Polymer serverside, i'll always be longing for React.
edit: Come to think of it.. If someone could bake html imports and shadow dom into React, i may be in heaven.
I do think that long-term (5+ years) something like Polymer will become the preferred solution. For now, imho, React is about as good as it gets for componentized web applications.
Everything is a view, even components that are structural more than visual. You achieve an MVC-like separation by designating some components as being owners of data, but it feels awkward.
Facebook's Flux looks like it may be a good solution, but I haven't tried it out yet. At any rate it is more about data flow than high-level application orchestration.
However, the polyfills + ammount of http requests in a very modular project don't inspire the confidence that Polymer is ready for prime time.
My thought is that when web components lands in browsers natively, and if some of the request problems are smoothed over, it would be easier to translate a react project than a project in another framework. You could replace things piecemeal. But by then, who knows how much more compelling react might be.
React is backwards compatible to IE8. Polymer? Not so much. Unless you live in that mythical world of evergreen browsers, Polymer is sort of just a really great demo.
http://facebook.github.io/react/docs/working-with-the-browse... http://www.polymer-project.org/resources/compatibility.html
Anyway the more traffic your site gets, the harder it becomes to ignore certain cohorts.
It's also not intended to support older browsers; I'm okay with that.
Aren't you tired of having to query the DOM tree and manually manage the structure to create UIs? Web Components doesn't solve this at all, it just tries to encapsulate the work. The problem is that building apps is building components, so you inevitably are forced back into the manual DOM management to create your app-specific components (like how you constantly have to create directives in Angular). You also need to jump into JavaScript to configure and wire up any Web Components you used. It's a very messy abstraction, and fools you into desiring a pure HTML-based declarative way to write apps, which is like wanting steak but eating liver.
See http://jlongster.com/Removing-User-Interface-Complexity,-or-...
Technically i use Node, but only to implement a small interface layer for things like http requests. So i don't really consider it a Node app. The real code is all React and Golang.
Unfortunately, this approach does not work very well in the cases where I have multiple instances of the same component, in which case all the parents will be recieving and handling the event emitted by a single child. I would love to hear any possible solutions for this that do not involve either registering unique event names for each instance of the component or passing in a unique id as part of the event payload, which is then verified by the handler function.
http://facebook.github.io/react/tips/communicate-between-com...
I would be over the moon if React had a UI Kit that could be included. We need more app-centric first UI options for rapid development.
[1] http://www.polymer-project.org/components/paper-elements/dem...
Oh and don't get me wrong that this pattern gets used again. I can see it being extended here and it looks really nice and promising. I just don't understand the sudden hype.
React does not ship with any code for saving your data to the server.
I'm looking forward to try React myself, but haven't yet.
Seems like React is here to stay and become really really awesome, I haven't heard anybody say bad things about it.
They all replaced backbone with react? I haven't really used either, but I thought a lot of people used backbone and react together, since they excel at different things.
My friends and I also just launched Vim Awesome [2], which is not "large" but is completely written in React and is open source if you're curious to look at it.
Edit: Or this may be due to the fact that we don't properly cache the fetched plugin list on the client side so we end up re-fetching it when you go back. Either way, this is not a React problem.
Pull requests welcome!
I made the decision to switch from Backbone.View to React about ~2 weeks into the project, and so far I'm extremely pleased with it and have not regretted it! Unfortunately, the code isn't open source though.
I do this by attaching a callback on the sync, add, change, remove events and use the the toJSON() method to copy it to the React state like so:
this.setState({data: this.props.model.toJSON()});
When saving a form, I have a method which handles the form submission. It copies over the state to the model and then saves it using:
this.props.model.set(this.state.data);
this.props.model.save();
In additional to this, I've built a tiny dispatcher to instantitiate my models and collections only once. In this way all parts of the app will always work on the same data and by in sync.
but not open source
It isn't using JSX yet because CoffeeScript integration didn't exist until recently, but it was still a joy to use.
There are a few guidelines we have adopted through trial and error so far:
* Use React.addons.classSet[3] liberally. Class name generation becomes simpler for future developers to read.
* Define propTypes[4] for every component. Debugging becomes easier because React gives you informative warnings about mismatched propTypes.
[1] https://github.com/mesosphere/marathon
[2] https://github.com/mesosphere/marathon/tree/master/src/main/...
[3] https://facebook.github.io/react/docs/class-name-manipulatio...
[4] https://facebook.github.io/react/docs/reusable-components.ht...
I have been distilling all the lessons learned into a lesson plan: https://github.com/zbyte64/reactjs-crashcourse
My one suggestion: host it on github pages and put a link to that in the README. It's already basically ready to roll. Way more accessible than downloading a zip and opening an html file.
www.camlistore.org
https://camlistore.googlesource.com/camlistore/+/master/serv...
Shorter time to ship, fast UIs and less bugs (because it's easier to reason about state).
http://facebook.github.io/react/blog/2014/05/29/one-year-of-...
For those who don't know, Glimpse is an OSS diagnostics platform and we are in the process of building out v2 (including NodeJS and .NET backends) - http://getglimpse.com.
Current work on the front end can be tracked here - https://github.com/glimpse/glimpse.client/tree/version-2. Very much a work in progress but all good so far.
The system is quite large. In the end it will contain several major "sub applications" that users can switch between and each "application" has large number of components, major interactions, etc.
We are currently using the following stack:
- Views - ReactJS, - Server Comms - Superagent + Primus (SocketIO), - Build - Gulp, - Packaging components - Webpack, - Module System - CommonJS, - Message Bus/Dispatcher - Postal.js, - Testing - Jasmine, Jest, Chance, Karma, etc
I get that the creator advertises it here pretty heavily, an that's cool. Doesn't mean everyone else has to as well.
That said, I have a bad impression of Mithril, because, in any case, its author should bear some respect to React, as a son to his father. But, instead, he appears very arrogant when talking about React (look here: http://lhorie.github.io/mithril/comparison.html#react) as if it was React that was inspired by Mithril and was reimplement Mithril ideas with worse performance.
That bad impression, caused just by words (and other comments from its author here), pulls me away from Mithril, which is a situation I don't love.
But I built my web-apps with a similar pattern for years.
Keeping an virtual structure of my components and rendering the delta to the DOM when finished, so React didn't seem like a big deal for me. But I liked, that they baked the idea into a reusable framework.
But you should try writing React templates in pure Coffeescript[1], perhaps reusing your HTML through a tiny tool[2] I wrote for it.
[1]: http://blog.vjeux.com/2013/javascript/react-coffeescript.htm...
What is that? No, no, no, stop that! You're becoming Angular!
_________
Now seriously: there should be a way to turn React from a library to a DSL that could be rendered by any language, so all servers, not only Node, could generate their pages in React and pass them to the browsers.
Event handling could still be javascript, as servers don't need them, but code that rendered elements according to specific this.props should be universal.