Hacker News new | ask | show | jobs
by drcode 4383 days ago
Is it feasible to use react.js and polymer together in an app?

I mean, is it possible to do this without sacrificing the benefits of reactjs by simply writing state-ish code in reactjs?

(At first blush, I can't think of a sensible way of doing this...)

2 comments

Haven't tried it but you can integrate React with pretty much anything. Looking at the Polymer lifecycle methods[1], I'd start by trying a `React.renderComponent` in Polymer's `domReady` callback for an element and then setState/setProps/forceUpdate in the `attributeChanged` callback.

[1] http://www.polymer-project.org/docs/polymer/polymer.html#lif...

That said, I don't expect it to be common since you'd basically be building a React component with a Polymer shim and getting almost no leverage out of Polymer. I suppose you could write some code to parse out the html template and turn it into React.DOM equivalents but that seems like a lot of effort.

All React integrations I've seen are the result of introducing React into a legacy codebase or they're using React on a component that's rendering a very large DOM subtree and taking advantage of React's O(N_view) instead of O(N_model) scaling and batched updates for perf wins over current KVO techniques.

Yeah, what I'd want is the polymer "look and feel" and the react update model... doesn't seem like that's possible.
Completely agree that the Polymer Material "look and feel" is really nice and well thought out. The WebComponents ideas it is based on gives me the jibblies though.

You could do the polymer look and feel with the react update model via famo.us (disclaimer: I work for famo.us). Famo.us also plays pretty nicely with Ember.js (tutorials coming soon) and React.js.

That's not really doable. I'm building a React based component/widget system for work and assuming all goes well and I can OSS it there's a reasonable chance I'll build out a Material/Paper widget set since I really like this set of design guidelines.
Mixing them both together would be nasty (components are central to both APIs, it'd be counterintuitive), but using React as a fallback layer doesn't sounds so bad