React Enlightenment
reactenlightenment.com
reactenlightenment.com
I find this often isn't the case unless, say, the dev comes from an Angular background (who is more likely to structure code in a top-down fashion, rather than React's recommended bottom-up components-first structure). I've seen a certain tendency to overcomponentize upfront (because hey, "Thinking in React" says to make a lot of very small components), and then see the components gradually grow in configurability over time, exposing more and more ad-hoc props for whatever "configuration" is needed at the time.
I've asked other React developers the same before, but so far the links I've seen are of "apps" that could be made with tops ~120 lines of vanilla JS... :|
The elements, styling, and interaction listening is React for Web.
The equivalent of the above in React Native is... React for native.
Remove all that stuff specific to each platform.
What is left is React.
Honestly React could be considered it's own design pattern [or a renaming of existing], with fb/ReactJS and fb/ReactNative being the most well known implementations.
What React does, is keeping the DOM tree in sync with the data (components' states and properties). If you don't have the state - it might be the case that you don't really need React, something like Handlebars.js or jQuery templates (if there's even a need for templating at all) would do just fine.
I mean, there's no real practical difference[1] between something like
// A stateless React component, so no need for React.Component boilerplate
const MySelect = (props) =>
<select name={props.name}>
{ props.values.map((v, i) => <option value={i+1}>{v}</option>) }
</select>;
// For this example to be short, no trees here. Only one component.
// (although internally <select> and <option>s are - but we don't care yet)
// And, actually, in my opinion React only starts to make sense
// when there's a big enough hierarchy of components (stateful or not).
ReactDOM.render(<MySelect name="x" values={["foo", "bar"]} />, targetEl);
And something like const MySelectT = Handlebars.compile(`
<select name={{name}}>
{{#values}}<option value="{{@index}}">{{.}}</option>{{/values}}
</select>`);
// Same as ReactDOM.render for one-component case. For nested, use {{include}}
// However, note now here's an important difference - unless the templating
// library is more powerful, the state is monolithic (and has to be defined
// implicitly, in full) with this approach.
$(targetEl).html(MySelectT({name: "x", values: ["foo", "bar"]}));
[1]: But there's no difference only when you keep it at this level.But if your UI is dynamic enough and you start to care about the state (e.g. you don't want to lose user input to template re-rendering, when user switches the tabs back and forth) - React provides a way to handle this by one-way binding between your data structure and DOM tree it handles. All it does, though, is only handling of that DOM tree and handling/propagating state updates (esp. if you combine it with Redux) - all the rest is yours to code.
It's a lot of code compared to a static website, but not a lot of code compared to doing it in some other framework, and, for many cases, it is much, much more maintainable.
THAT SAID, I agree that it's a horrible example to have on the first page.
"Here, let me show you pages and pages of scary code that won't make any sense until you've read the entire book, in an attempt to give a brief overview of this framework."
I think there could be a much gentler introduction, preferably using JSX.
If all you want is a select in React, you can just do `<select><option value="A">A</option><option value="B"></option></select>`. The tutorial is showing how to roll your own select-like control using divs. I doubt that it is much easier to do that using any other JS framework.
Yes, of course it is. But reading a tutorial about how you could implement something so understandable as <select> using React is a pretty good guide to understanding React! At least, to me it seems pretty great.
If "enlightenment" is realizing you can use React to reinvent [insert-library-here], then what's so special about it? Any half-decent framework can do that. I think the argument about composability and scalability (which imho are the real value-add that React brings over e.g. jQuery) is a bit lost in that example because it spends so much time on stuff that looks rather pointless and mundane.
The component pattern is certainly not unique to React but it is a good design pattern that the framework encourages through JSX, component lifetime cycles, etc. While I can't speak for everyone, React has certainly made my life and the life of developers I work with easier since integrating it.
Basically, Web Components exist to solve a different problem than React.
> WebComponents provide strong encapsulation for reusable components, while React provides a declarative library that keeps the DOM in sync with your data.
You can use something like reflux with web components to do this too. The fact that react uses virtual dom is an implementation detail I think.
Maybe I'm missing something obvious here.
Even react tutorial operates with components: https://facebook.github.io/react/docs/tutorial.html
Well that is just entirely pretentious.
This is a verbose re-statement of components, which are not new.
Before React, you couldn't do this in a performant, UX-positive way
Has there never been a performant component based UI framework?
Contrast this with two previous approaches. The first is where you have a component hierarchy that renders the initial state of the view, but when the data changes you need to write imperative code to transition the native views to reflect the new state. The second is traditional data binding, which doesn't help when you want to change the view hierarchy itself (rather than properties of existing views) based on an underlying data change.
One of the closest items to the "React Enlightenment" book might be "Redux Without Profanity", a free e-book posted at https://tonyhb.gitbooks.io/redux-without-profanity/content/ . (Which, oddly enough, I'm suddenly noticing is _not_ already in my list.) The slides at http://slides.com/jenyaterpil/redux-from-twitter-hype-to-pro... are also a great intro and overview of how Redux works.