Live data from Hacker News

React v0.14 Beta 1 released

facebook.github.io

31–40 of 62 posts

Re: React v0.14 Beta 1 released

#31

we looked at what you can do with a ref to a DOM component and realized that the only useful thing you can do with it is call this.refs.giraffe.getDOMNode() to get the underlying DOM node. In this release, this.refs.giraffe is the actual DOM node. This only holds if you use Facebook's particular flavour of Flux, I guess. Personally, I use refs a lot to bubble events down the component hierarchy. For example, when the…

You must have misread the blog post. This change only affects DOM components like , not composites like your . I wrote in the post:

References to custom component classes work exactly as before.

Re: React v0.14 Beta 1 released

#32

Earlier quoted context omitted.

I'm not convinced that's true. I do agree to the extent that things like PhoneGap do result in compromises. But React Native is basically a templating tool for native apps – you're still free to write whatever native components you require, but can compose these using React, which is pretty cool. You can then abstract the higher-level components across platforms.

Why would I want to compose native using React?

Probably nothing for the regular mobile-dev. But many of the web-devs can leverage their JS knowledge and hit the mobile-market without "web-container-apps".

Re: React v0.14 Beta 1 released

#33
post #11

If you haven't already, you should be betting on React. It's the future: > More importantly, this paves the way to writing components that can be shared between the web version of React and React Native. This isn't yet easily possible, but we intend to make this easy in a future version so you can share React code between your website and native apps. Isn't this what we have all been waiting for? Writing components t…

It's the future http://blog.circleci.com/its-the-future/

For CircleCi, it's the present. Their frontend is written in Om, a cljs wrapper around React.

https://github.com/circleci/frontend

https://www.youtube.com/watch?v=LNtQPSUi1iQ

Re: React v0.14 Beta 1 released

#34
post #21

Aren't these two changes in conflict with each other? One change remove assumption about DOM as rendered target, while another change means DOM must be the rendered target. Requiring ReacDOM.findDOMNode(ref) should be what they do if they want to encourage multiple rendering target.

If you use a ref to a DOM component, you don't need ReactDOM.findDOMNode at all. Calling findDOMNode on a composite drills through abstraction boundaries and breaks encapsulation, so it's rarely what you should do.

The removal of .getDOMNode() was intentionally done in concert with this change: previously, all component classes created with React would magically have that DOM-specific method added to them; this way, component classes are less tied to specific rendering environments. If you need to call ReactDOM.findDOMNode then yes, your components will be tied to the ReactDOM renderer.

Re: React v0.14 Beta 1 released

#35
post #19

we looked at what you can do with a ref to a DOM component and realized that the only useful thing you can do with it is call this.refs.giraffe.getDOMNode() to get the underlying DOM node. In this release, this.refs.giraffe is the actual DOM node. This only holds if you use Facebook's particular flavour of Flux, I guess. Personally, I use refs a lot to bubble events down the component hierarchy. For example, when the…

This is only true for DOM components, e.g. an component, which can't have a onWindowShow() method associated with it. Customer components, e.g. an component that wraps a DOM and provides custom onWindowShow() functionality are unaffected.

Ahhhh of course! OK that makes a lot of sense. Actually, it makes is more uniform: a ref has whatever properties and methods that ref could possibly expose - be it a "built-in" component (aka a DOM element) or a custom one. Nice!

Re: React v0.14 Beta 1 released

#36
post #31

we looked at what you can do with a ref to a DOM component and realized that the only useful thing you can do with it is call this.refs.giraffe.getDOMNode() to get the underlying DOM node. In this release, this.refs.giraffe is the actual DOM node. This only holds if you use Facebook's particular flavour of Flux, I guess. Personally, I use refs a lot to bubble events down the component hierarchy. For example, when the…

You must have misread the blog post. This change only affects DOM components like , not composites like your . I wrote in the post: References to custom component classes work exactly as before.

Yep, I'm blind :-) Thanks!

Re: React v0.14 Beta 1 released

#37
post #11

If you haven't already, you should be betting on React. It's the future: > More importantly, this paves the way to writing components that can be shared between the web version of React and React Native. This isn't yet easily possible, but we intend to make this easy in a future version so you can share React code between your website and native apps. Isn't this what we have all been waiting for? Writing components t…

If you haven't already, you should be betting on React. It's the future

But last week the future was AngularJS, and the week before that it was Ember or Backbone or Knockout, and a few days earlier it was jQuery. Next week it will be Angular 2.0, maybe, or something with Web Components, and the week after that we're all abandoning JS in favour of some declarative functional language that hasn't been written yet but will be on TodoMVC tomorrow.

Seriously, this is a beta of a pre-release package. The article mentions, as motivation for the major architectural change, some other react-something packages, and literally in the opening section of their README.md they say things like "This project is a work-in-progress. Though much of the code is in production on flipboard.com, the React canvas bindings are relatively new and the API is subject to change."

By all means let's experiment with newer and potentially better ways to build sites and apps, but betting heavily on an ecosystem this immature for a long-term professional project seems like asking for trouble.

Isn't this what we have all been waiting for?

It's certainly not something I've been waiting for, as someone who works in the relevant fields. Rather like "isomorphic" libraries, I feel combined web/native generation is mostly a solution in search of a problem. No doubt a few people really do have that problem, but I'm guessing that for most day-to-day work in the real world this theoretical flexibility adds little practical value. There's no particular reason the same tools should be good choices for writing both web and native apps, any more than we should expect the same tools to necessarily be good choices for writing both server-side and client-side code in a web app.

In this particular case, I'm more concerned by the change in emphasis than the technical changes. To me, the big advantage of React over most other front-end libraries and frameworks is the efficient DOM updating, which in turn makes this kind of component model viable with acceptable performance where various other UI libraries/frameworks have struggled in the past. However, it looks like the React team think that is a secondary benefit and the real advantage is using components.

I can already build a complicated web app rendering layer using the same modular design skills I've spent the last 30 years learning in other programming contexts. After all, that's what I did before we had the modern generation of template/component driven frameworks, when we had to update the DOM manually using plain JS or libraries like jQuery. So did plenty of other people. Maybe I'm missing something, but while React might be a sensible enough choice for part of the UI rendering work, I don't see why it has anything unique or special to offer compared to many other libraries here.

If the React team focussed on the efficient DOM updates, flexible but reasonably simple component model, and then stability so the community could develop the ecosystem around a solid foundation, I could see it becoming a good choice for projects that can't afford to have their dependencies constantly shifting around and the maintenance overheads that incurs. But this separation and increased emphasis on react-native and the like feels like it's leaving behind the very things that made React attractive in a very crowded field of JS UI libraries.

Re: React v0.14 Beta 1 released

#38

I am using/loving React a lot and is already in several production apps I am working on (thanks for awesome work Facebook!) but I don't fully get this release. I feel it's a bit premature to separate `react` and `react-dom`. React has proven itself for the web but still has to prove itself as `react-native` and I don't get the friction/complexity being added by break it down into two components for the web. I feel Re…

Chances are this clear separation will allow the various teams to submit patches to React without having to worry about time synchronizing with the release of the stuff that is in ReactDOM ... at least once it stabilizes a bit.

Re: React v0.14 Beta 1 released

#39

we looked at what you can do with a ref to a DOM component and realized that the only useful thing you can do with it is call this.refs.giraffe.getDOMNode() to get the underlying DOM node. In this release, this.refs.giraffe is the actual DOM node. This only holds if you use Facebook's particular flavour of Flux, I guess. Personally, I use refs a lot to bubble events down the component hierarchy. For example, when the…

Personally, I use refs a lot to bubble events down the component hierarchy. For example, when the browser window loses focus and gains it again, some sub sub component of the root component might want to do set some local state. Whatever, display a "welcome back!" message or something Isn't that a bit of an antipattern? It seems that sending events down the hierarchy is something that React goes out of its way to mak…

I'm not sure that it is an antipattern. Personally, I feel that attaching event handlers to global window events from all over the place is just as bad, basically a singleton in disguise.

Another use case that I came across was where we wanted a search dropdown to open in the header when a user clicked somewhere in the middle of the page content. One option would be to make a PageStateStore and add an isSearchDropdownVisible to it, but I don't like doing flux that way because I don't want UI details to be part of my model later.

I think having isVisible in the SearchDropdown state is much more elegant, but that poses the slight problem of how to change that state from the other side of the page. We did that by having the item in the page have an onWantToSearch event, which the page had a handler for that invoked this.refs.header.showSearch(), which in turn invoked this.refs.searchDropdown.setVisible(true), which did a simple this.setState({isVisible: true}).

So, in general, the event first bubbles all up the tree (through custom react onSomething, onSomethingElse props), and then bubbles down the tree (through method calls on refs). This exposes a really elegant design, because it made the Header component be "a thing that allows searching" (because it has a showSearch() method), and the page item an "a thing that allows a user to initiate a search action" (because it has a onWantToSearch event). The available methods and onSomething props of all components perfectly matched the possible behaviors of the components, and no behaviour is "hidden" inside a singleton mesh of flux stores.

Re: React v0.14 Beta 1 released

#40
post #3

I am using React and am very happy with it, however I worry about upgrading because of the interdependencies as well as how fast everything is moving in this space... Does anyone know when we'll be able to have a 1.0 release that we can assume stable for a few months and that react-xxx authors can make sure their modules are stable against. Presumably the react/react-dom breaks all current third party packages for no…

It was this way with Backbone a few years ago. Give it time, it will calm down eventually. Breaking changes are often necessary to get a project where it really needs to be.
Post reply on HN