New React Developer Tools
facebook.github.io
facebook.github.io
So the problem for me was not React being bad or Angular better but at the end of the day it has to do with: As a non-fulltime webdev I need a _complete_ widget/component library available for when I want to build my apps. With React I felt like I was constantly either having to look for components that kind-of/sort-of worked for me but had some short falls or I had to build them from scratch. Then there's the look and feel so you're either looking for components that are Bootstrap ready or Material Design-ish, etc. Even then, you take Angular Material: it's not there yet. Go to the website. That side-nav menu they have going is really nice. I wanted to use that in my app. Is that an MD component? Nope. It's a hacked together mess of custom things. Talk about "eating your own dog food".
Is this common place in the web world right now? Regardless of choosing React/Angular/whatever. I mean I'm used to QT. There's a widget for just about anything. You just wire up your events and you have an app. It seems like the web world is slowly just going to end up reinventing Delphi at the end of the day when I look at things like Polymer (why has it taken so long?)
All these frameworks are great but can we please just work on having feature-rich components/widgets now. And maybe keep them maintained for the next 5 years or so?
You might want to check more enterprisy frameworks like extjs.
One of the reasons I've seriously been considering React for even a lot of back-end stuff is that it's really easy to create an isolated component that combines markup, styling and behavior. Once done, I can simply require() the component on either the back- or front-end, or both, and reuse the component in other projects.
Granted, for styling there's still no solution that I consider optimal, but the advantages might be worth the 'impurity' of it all. And solutions are being worked on.
And granted, there are other initiatives like Web Components that are hopeful.
But already now React is a great option if you want to create 'independent' and re-usable components. I think it's just a matter of time before a proper, popular component-ecosystem arrives, and what with React Native, there might even be some degree of 'unification' across platforms.
That's assuming we won't abandon React en masse and switch to another even cooler solution in a few years, though :-/.
No. This is the web. We must reinvent everything every 5 minutes.
React isn't that. That's fine - it's not supposed to be.
Hell Angular isn't that... but as it's a framework (React really isn't it's a View library) it has more of that. Angular + Bootstrap probably does most of what you would want...
... but it's an extremely narrow need. Not a general case.
I was under the impression that at the end of the day you're creating either React components and/or Angular directives when you're building a web application. And the particular framework takes care of how the view changes when the model changes, it provides you with some abstractions like Resources (to talk to REST APIs) and Routers (for navigation). Even when you look at ExtJS I don't see why they couldn't provide ReactExtJS or AngularExtJS by just wrapping their widgets so that you're either creating them with "props" or by specifying the initial "scope" if you're doing it Angular directives, for example.
Creating standardized widgets which can be "wrapped" to expose a React (prop/state) or Angular (isolated scope directive) style interface, and then "skinned" (Bootstrap or Material Design or whatever) I would have thought would be the logical thing to do. As another poster commented, perhaps this is what people are calling "Components"? However, I'm pretty sure it could be done right now with what we currently have.
If you say it's an extremely narrow need, I understand because typically I end up facing problems no one else seem to have :)
I like your idea of writing generic code and then expose it to Angular/React/Ember.
Including something like Backbone/JQuery would probably be harder, since it uses direct DOM manipulation. But those other frameworks have livecycle-hooks that get called when a component is rendered and have to provide the framework with virtual-dom/handlebars/etc.-templates that get injected at the right position.
Since A/R/E don't have their own CSS (contrary to ExtJS) the styling code could be generic too (which it already is in most web-apps, with the help of Bootstrap).
Do we really need a R/A/E/*-bootstrap everytime a new framework comes out or can we build something more generic like this (R/A/E)-[general_component_library]-(Bootstrap/Material Design/Current Button Style Trend)?
If you're using MaterialUI, or React-Bootstrap, you should be able to compose what you want out of more primitive components... yes, there's work there, and it isn't magic... if you want something more polished, nobody is stopping you, or anyone else from writing/creating it or paying someone to do it for you.
Just like there's fragmentation with desktop apps... QT, wx, GTK and that's just a handful for Linux alone. That doesn't include all the Windows and OSX UI packages over the years... The web is far more flexible and diverse in practice, and also more open, so you simple see more of the options.
MaterialUI, MaterializeCSS and Bootstrap are all decent starting points... depending on what you want to do. If what you want is a nice table widget, nobody is stopping you from making one... become part of the web community you're complaining about...
If you aren't part of the solution, what are you? In this case you're supposed to be a programmer, with an itch to scratch... scratch, and share.
I don't see how this is really all that different from components in any language/environment/platform... yes, there is fragmentation.. and yes, you can mash things together, doesn't mean you should, but you can.
That said, it's an itch that has been scratched, if it hasn't been scratched for your tool of choice, dig into that... the fact is that more people are working towards enhancement from phone to desktop, and being able to work with similar controls at different sizes/rendering... table controls don't really fit outside the desktop model, which is probably why there aren't more options for react, and probably more for angular than react at that.
Toolkits of the kind you're looking for (ExtJS/Dojo etc) just haven't really taken off. ExtJS suffers from having an all or nothing approach to its usage, and last I checked its approach left much to be desired. Dojo is a bit more flexible in that sense but both libraries are big and complicated as they have to do a lot of work to achieve the behaviour they require of the browser.
Browsers simply aren't designed (still!) to provide the grid-like layouts required by apps. It's generally best to avoid the complexity required to do this unless you have no choice.
Flexbox promises to make grid layouts much easier. I have to admit, the last time I tried to work with it I found it quite difficult to get to work for me.
Web components promise to raise the number of available HTML elements by creating your own. The are indended to help you move from code like `$('.datepicker').datePicker()` to HTML like `<datepicker />`.
Fundamentally, there is not going to be a standard way of doing things on the web because there is no such thing as a standard website. When you visit a website today, you could be visiting an API, an RSS news feed, a database interface), a drawing package, a computer game, etc.
Such diversity of applications requires a diversity of tools and approaches, and that is what we are seeing a proliferation of today as we explore and discover the most successful ways of providing digital content.
Keep in mind though, the environment QT runs in is very different to the web, so most of us poor web devs are at the mercy of browser vendors, and as such we're often limited by the lowest common denominator.
So a lot of the work that traditionally went into widget/VCLs/etc. is immediately not necessary and probably even unwanted. You basically have to reivent large parts of the wheel anyway. The rest is often largely component-independent, mostly event handling and data binding. So a very generic component often wouldn't help you that much, which is why a lot of the MVC libraries and frameworks available often seem to "skip" that part.
One noticeable exception is ExtJS, which seems the single remaining major toolkit aiming at desktop-like applications. There you've got your standard FormPanels, GridEditors and AbstractSelectionModels. There the tables turn, and HTML/CSS is often just used as the totally abstracted away presentation layer, and you just arrange widgets in JavaScript. That means a considerable payload, and more problems if you actually need to have something more "web-like" (boy, the horror of XTemplate).
For enterprise/intranet apps this matters less, of course. Which is why Ext is still rather common there and why they can afford to actually demand money for their library, despite all the competition.
But again, you probably wouldn't build gmail/instagram/facebook with Ext.
This thing will never change, whether with React or Angular.
Web dev, due to custom design of pages, is not like using native (Cocoa, Windows Forms etc) widgets where one-size-fits-all. It's more like native apps with custom skins and widgets.
We "can", and maybe there are already quit a few. However, the thing about UI is that it's more than the sum of its parts; experience is holistic, and a UI should be conceived as a whole, not as something assembled by common components.
This is fundamentally a difference between disciplines. As a developer, you'll think that reusable and isolated/modular widgets are the way to go; a UI designer, on the other hand (and not forgetting consistency), will/should(!) adapt the UI to its users and contexts.
[1] https://docs.reduxframework.com/core/getting-started/ [2] https://github.com/acdlite/redux-react-router [3] http://material-ui.com/ [4] https://github.com/erikras/react-redux-universal-hot-example...
The problem with React is that the core team has explicitly stated that they are not worried about compatibility with Web Components, so if you stick with that framework over the long term you may find yourself shut out of that bright future. The Angular team re-wrote their framework mainly because they wanted to be compatible with the upcoming Web Components spec.
So, yes, it's a mess, but it's about to get a lot better. Hop over to https://www.polymer-project.org/1.0/ to get a glimpse of things to come.
What's great about Web Components is that they don't need custom developer tools. The DOM tree _is_ your component tree, the browser naturally highlights custom elements, just like built-in elements. Editing the DOM and CSS just works. Placing an element into a temp variable and setting properties just works.
The first and most basic is that the expectation on the web is that every project will have a unique look and feel. This greatly limits the adoption of frameworks based on desktop widget library concepts (dojo, ext, sencha, cappuccino, sproutcore). The times I've used these frameworks, I spend as much time fighting the look and feel as I would building an interface from scratch. This isn't a problem if you're look and feel insensitive and desktop style widget libraries do get picked up for internal corporate apps.
The second problem is size. The need to download everything, desire for reduced page load times, and lack of dead code elimination has historically made web devs more sensitive to the size of their libraries. This was a problem for libraries like YUI2, which had excellent components that simply had an option for anything somebody at yahoo wanted but adding a new widget would frequently add hundreds of K to the download. This is a reduced concern with the increased capabilities of mobile and I believe that the combination of HTTP2, having a standard module system, increased tooling (e.g. webpack), universal/isomorphic JS, and ServiceWorker provide the means to more or less eliminate this as a core problem.
The third problem is CSS. The language provides no tools for abstraction when the target markup (your widget) is fixed. Happily, this problem is solved via sass. You can separate style concerns into mixins (or placeholders) and compose them into either widget or instance specific rules and avoid the cascade.
The fourth problem is component composition. In order to get more code reuse, you need to be able to build up bigger widgets from small pieces and then make a lot of useful small pieces. Stateful components don't compose particularly well and I've spent a lot of time on this (in yui3, knockout, and angular) before I found React's virtual dom approach two years ago. With the vdom, it's possible to view components as functions projecting state onto a virutal DOM. Composition can then be solved by creating higher order components and using normal functional programming composition and code reuse. With care put in to how larger components are designed, it's possible (I've done it) to swap out sub components to customize behavior on a per-instance basis. I consider the core problem solved but I haven't seen the equivalent of an underscore for react components yet.
The fifth problem is widget interaction. I define widgets as components that are an isolated concern (and generally maintain internal state): Autocomplete instead of FooList. Since the components are generally stateful and produce events, you have to have a protocol for having them interact with each other and the rest of the app. As an example, a FOO widget is a React component has PropTypes that get compiled into a Falcor query and all its event handlers call a function `dispatch` with an object shaped like X. Everybody comes up with this in their app but without a consensus on what the approach is, everybody's widget libraries are parochial. This is an active area of development and Web Components is Google's take on the problem. Facebook is also very interested in this with Flux/GraphQL.
Once all the problems are solved (I believe we're relatively close) then we should see widget libraries come into their own. I'm estimating about 3 years before someone starts really winning the widget library battle and we get a "standard" set of widgets you're looking for. I believe that something from the React or Ember communities are the likely source and Polymer has an outside chance (I don't see how component composition works in Polymer).
Thank you for posting this. I've been wondering if this was possible. Can you share any insights that might help someone that wants to do this?
// In your components...
let DefaultListItem = (content) => <li className="foo">{content}</li>
let DefaultList = (items, Li=DefaultListItem) => <ul>{items.map(Li)}</ul>
let SortableItem = (content) => <li className="handle" on-drag={(e) => dispatch('dragStart', hash(content))>{content}</li>
let SortableList = (items, Li=SortableItem) => <DefaultList {...this.props} />
let EditableList = (items, List=DefaultList, Li=SortableItem) => {
<div><List {...this.props} /><button>Edit</button></div>
}
let SearchResultHighlighter = (text) => <span className="imagine-this-highlighted">{text}</span>
// -- In use...
let source = ['foo', 'bar', 'baz']
render(<SortableList items={ source.map(SearchResultHighlighter) } />)
let ImageItem = (url) => <li><img src={url} /></li>
render(<EditableList items={ source.map(x => x + '.jpg') } Li={ImageItem} />)
There's a lot of design space to play around with. For a widely reusable library, I want something like Clojure's protocols or Rust's traits so I can indicate to people what the component needs/provides without them looking at the source.Because standards, you can compose Polymer elements with native elements or custom elements built with or without a helper library like Polymer.
What part is confusing?
I used to think that a lot of their projects were trying too much to re-invent the wheel, but now I see it as an uncompromising attitude towards having the most streamlined development experience. I also really appreciate the strong commitment to open source.
This is contradictory.
[1]: https://github.com/facebook/react-devtools/ [2]: https://github.com/facebook/react-devtools/tree/master/shell...
But I'm happy to hear the original statement isn't totally accurate.
Also, Google builds tons of things for the developer community. Anguar, Google fonts, Material design, and more, are centerpieces of many modern websites.
If anything they did a great disservice to the spirit of open source by including this in their oss
https://github.com/facebook/react/blob/master/PATENTS
I honestly don't care about any of their oss, but this is setting a dangerous precedent .
But Facebook made changes since then: http://www.infoworld.com/article/2908879/open-source-softwar...
I don't know much about it, just giving you links.
No more faffing around with marshalling/demarshalling and such a simple API code generation on client & server aren't even necessary. Plus, react makes the UX incredibly responsive and in future I should be able to use the same server as a backend for native IOS and Android apps which I'm hoping should be pretty quick to chuck together once I've worked out the business logic for a website. It's like a different world since last time I did front end work, and I think this time I might actually be able to create the app I want to, while having something that's maintainable and boiler-plate free. Thanks Facebook!
Something like GraphQL or JSON API might be the right choice in the future.
I guess there's no parallel for react-native though, which is really the killer feature for me. GraphQL & Relay are really the icing on the cake.
It's like going from IE Dev Tools in IE7 to Chrome Dev Tools. Night and Day.
EDIT: Apparently the tools don't work for local dev. Just hosted the files behind a python simple httpserver.
python -m http.server 8000
did the trick.Seeing something like this, and the strength of having developer tools like Ember Inspector or React DevTools, is just going to make frontend development so much easier.
When interacting with a complex web of routes, models, components, and templates, I have found Ember to be similar to Rails in terms of expressiveness and speed of development.
Then again, I don't know a lot of the tools that people use to solve these problems in React- the most I ever encountered was having to do most things manually, but having page layout managed by React. I was still managing my M and C. What do you usually use to ease the work there?
When I say that I use React it includes the whole client-side stack.
React, react-router (inspired by the Ember router), Redux, react-bootstrap and newforms.
This is a bit like using Ember, Ember-Data, Bootstrap and ember-forms.
That's not much -- and all the projects are probably toy projects, to fit all of them in a week's span.
>while it's nice, it is what it is- a view layer.
Sure, that's why you use Reflux, Redut and some other Flux architecture helper to frame your code, ReactRouter, etc.
Or messenger.com, which is an impressive React application too!
Unless you mean does it work if you use React within a Meteor app. If so, it may.
I love React, but that just seems like a bad idea. Especially given the fact that the previous version was called "v2-beta".
Edit: Oh, I see we did. The version number in manifest.json and package.json was 0.14 though… I'll leave it like this but will bump it up to 2.0 if it causes any serious confusion.
What would be really awesome is if there was something similar to Chrome Dev Tools' "store as global variable" feature, so that I could edit props in the console and then pass back to React.
It's the idea behind it that is totally flawed and doomed.
React augments the complexity of a stack that it's already too complex, to an unneeded, non-sustainable and dev-unfriendly way in which we are supposed to use HTML tags inside JS scripts.
React is just a Facebook's own short-sighted solution to slow DOM manipulation. The fact that it is OSS doesn't make it necessarily a good thing.
React is not a product of love for a greatly engineered system, but obviously just a product of FB's understandable necessity to work faster "today and here", in order to keep bringing home their daily profit.
React is not a solution, it's a patch, a ugly one.
We are not forced to like it just because FB made it and made it OS.
Can DOM be faster? Maybe so. Does that mean React is a bad idea? No. In fact, React is Multiple Buffering[1] in the age of DOM. It is not that DOM is slow, it is that change of DOM triggers the layout and layout is inherently slow, because it is complex.
If you do not need re-layout on each DOM change (and most of the time you do not), React allows you to batch changes in a very clean way.
As it turns out, the fastest way to build + update DOM, is with the DOM... #mindblown (its also the only way ;))
I believe the actual pain felt, is one of ergonomics. This is largely related to what MrBra mentioned, it turns out a complex stack is complex I suppose we just need to keep fighting the entropy us developers like to add.
It's hard to unpack all of it without writing an essay.
The virtual DOM is just an implementation detail. In my eyes, React's big feature is that it is a declarative, component-based UI model. Look at React Native or ComponentKit - they are not built around the idea that CocoaTouch is slow, but rather that there are simpler ways to do UI than the traditional imperative approach.
> React augments the complexity of a stack that it's already too complex, to an unneeded, non-sustainable and dev-unfriendly way in which we are supposed to use HTML tags inside JS scripts.
In my experience, as I mentioned above, React actually provides a fantastic abstraction that makes it simpler to build UIs. I haven't found it to be dev-unfriendly at all, the opposite actually - I find that it is a highly pragmatic, productive and pleasant way to work. But I suppose that's a matter of preference. What do you find unfriendly about it in particular?
> React is not a product of love for a greatly engineered system, but obviously just a product of FB's understandable necessity to work faster "today and here", in order to keep bringing home their daily profit.
This point I must disagree with absolutely. I have had many interactions with people who work on React and from my point of view it is indeed a labor of love as much as any I've seen on an OSS project. Do you have any examples that you can point towards to back up your assertion? Just watch presentations by any of the React team members and you'll see that there are real people behind it that care deeply about it. Better yet, talk to any of them in person and see how excited they are! This isn't a heartless top-down mandated project by a massive organization to squeeze more money out, but rather it started off as a skunkworks project by a single engineer in his spare time who thought that UI could be simpler, that caught on within the company because it turned out to be a great idea.
> React is not a solution, it's a patch, a ugly one. > We are not forced to like it just because FB made it and made it OS.
Well, isn't the world beautiful, so many different opinions! I'm extremely curious what your preferred tooling is, or any suggestions you have to make React better. Maybe you could write a longer form essay to elaborate on your criticisms above?
Other than that, getting around slow DOM manipulation is only one advantage of React. There are many others, such as making it super easy to reason about complex code, for example by not having to worry about the excruciating details of how multiple event handlers that are bound to the same element will behave.
Separating the state from the DOM itself is a brilliant idea and the elegance with which React accomplishes this disproves your claim that it is simply an "ugly patch".
I don't think they are caching DOM. Instead of deleting and adding new elements, they are just changing the old ones to reflect the changes. Adding new elements are expensive.
If anyone thinks I am wrong then please provide a documentation link to the correct material
[EDIT] Not sure why some people try to be rude here. Where is your zeal to ask and learn?
1. Create full new version
2. Run a diff with the old version
3. Patch
Because of 1, it is bound to be slow (in a computational complexity sense). Based on the popularity of React and its wide acceptance, I wonder if people learn computational complexity theory anymore these days?
PS: yes I know there are tricks to make 1 faster, but these are really hacks (require extra thinking and are error-prone) and deviate from the original "React" philosophy (they are basically the old style of doing things), so these don't count.
Have you actually developed a large React app? Because you might be surprised at how fast React really is in practice.
This is (more or less) true now. It wasn't when React first showed up. Angular is also only just as fast when you actively code your apps in the same way as React (basically using a prop/state system but in an Angular way). This isn't also the method generally championed in Angular (1.x anyhow).
Ember was always pretty fast but post-React it changed a lot of how it did it's rendering... influenced by React!
So claiming that React apps are no faster is a bit disingenuous as the reason for that is because the other frameworks saw what React was doing and agreed with it.
You can use Angular 1.x in exactly the same way you use React by only ever using 1-way binding and constructing your entire application out of directives scoped to elements. The only thing Angular 1.x doesn't let you do is use JSX, but then again, you could just use plain old javascript and imperatively build up your DOM elements (which is what JSX does under the hood anyways) if you really don't want to have .html files.
Step 1 would be slow if it created it in a real dom but as it's not (that's why it's called a "Virtual DOM") and is in fact just an object representation of the dom it's actually rather fast.
After all - it's just an object tree, and that's quite fast to parse.
The diff part is probably the slowest part in the React chain actually - because it actually has to compare to the other (virtual) representation of the DOM. Deep comparisons are just... well they'll never be trivial.
But no, it's really not extra thinking, it's not error prone, and it's basically due to it not really being what you're describing it as.
Let's say that you have a page containing a billion little images. On every update, your React-enabled code needs to create a virtual DOM containing all those images. This takes time, regardless of whether the virtual DOM is fast. Hence my point.
And even if it may be only a few milliseconds for a hundred images, it will take seconds or even minutes for millions of images. And even if only 1 of the images changed. This is of course not acceptable.
Most programmers are already happy if it works for 100 images. However, imagine that the inventor of quicksort invented bubblesort instead, stating it is fast enough for 100 elements. From a CS point of view, this situation is just ridiculous.
Facebook clearly chose HTML syntax (JSX) to be familiar with how developers are used to interact with HTML, thus lowering the learning curve. As others point out, the JSX syntax is still beneficial when not targeting the DOM, as in the case of React Native. JSX is just a preprocessor, and no different than writing, say, Mustache templates.
What React brings to the table is a framework for declarative UI components. Functionally, React components are no different than, say, Backbone views (indeed it's quite trivial to port a backbone view to a React component), but the data flow principles promoted by React (unidirectional MVC, immutability, declarativity, discrete state transitions) are different, and somewhat novel in the UI/MVC space.
React is definitely not just a "patch". If you think that, you've clearly not studied it closely enough.