22 Amazing open source React projects
- 7 strengths of React every programmer should know
- React.js in Patterns
- React in depth - Good gitbook to learn
- Avoid binding when passing props
- Reverse Engineering React
- Hacking with React
- React Demystified
- Future: React Basic
- React in re-implemented in jQuery
- Qiita blog
- 9 things every React beginner should know
- React and ES6 - Part 1
- React Cheat Sheet
- RAW React!
- React Inspire - Curated sites built with React.js
- https://github.com/sindresorhus/awesome
- React Primer
- Essential JavaScript links
- Nice survey tutorial
- Navigating the React ecosystem
- ReactConf 2015 notes
- React Cheatsheet
- React Kung Fu
- Easy React Book
- Setting up Vim for React.js
- Comprehensive list of React resources
- Learn React in 8 mins
- Coding with React like a Game Developer
- React.js Best Practices and Tips
- Angular is easy, React is hard?
- Why and how to bind methods
React is truly only for UI. Put your business logic elsewhere in plain JavaScript objects.
The value of DI is that we can depend on abstract ideas instead of concrete implementations.
Why SPA? Imagine using Facebook where every like and every comment made you refresh the page.
Web Application has 3 parts
- Listen for user events
- Handle network events (XHR, WebSocket)
- Manipulate the DOM (Rendering)
Simplicity is prerequisite for reliability
KVO is built around Observables and Computed Properties.
After a while, you will see the "cascading updates" problem, where a ListView will trigger a side drawer for input and once done, hide the drawer, update the ListView and update the counter, present a new dialog based on the newly added list, etc.
- Context in React and Dependency Injection
- The land of the undocumented: The Context
- Issue #2112 - Switch the Context to use the parent tree instead of the owner tree
const Text = (props, context) =>
<p style={context}>{props.children}</p>;
Text.contextTypes = {
fontFamily: React.PropTypes.string
};
class App extends React.Component {
static childContextTypes = {
fontFamily: React.PropTypes.string
}
getChildContext() {
return {
fontFamily: 'Helvetica Neue'
};
}
render() {
return <Text>Hello World</Text>;
}
}- ReactiveTraderCloud
- Hackable UI builder for designers & developers
- react-baby-steps
- Percolate Studio's router
- JWT router example
- cosmos.js
- react-flux-jwt-authentication-sample
- fixed-data-table
- React router auth flow example
- Authenticated route example from Ryan Florence
- Avatar.js
- react-textarea-autosize
- Date Picker
<ReactFitText>- react-ui-builder
- Sample mobile application with React
- react-new-way
- react-es6
- Atomic
- Idiomatic React
- Web publishing platform
- sprintly-kanban
- reddit-mobile
- Tchaik
- Creating a real-time photo experience with Socket.io
- Trader desktop
- JSX style guide from Airbnb
- react-pacomo
- Khan Academy's style guide
- React-starter kit style guide
- React tips and best practices
- Think in Elements. Think about the
<img>element. It hassrc,width,heightproperties. It dispatchesloadevent when it is fully loaded. - Domain-specific components are "containers" and atomic components are "components"
- CSS Modules
- CSS Modules by example
{ this.state.show && 'This is Shown' }
{ this.state.on ? 'On' : Off }Move complex JSX out of render
// Notice the parentheses here.
var complexHtml = (
<Section>
<InnerSection />
<InnerSection />
</Section>
);
return (
<div>
{ complexHtml }
</div>
);import React, { Component } from 'react';
class Builder extends Component {
willTransitionTo(transition) {
// Check authentication
}
componentDidMount() {
this.databaseRef = new Firebase();
this.databaseRef.on('dataFetched', function() {
this.setState(...);
});
}
render() {
return ();
}
}If you need IE8 support, you need to include es5-shim yourself to make use of several Array and Date functions.
You are need to include html5shiv for IE8.
React.initializeTouchEvents(true); // But put where??- Christopher Chedeau, @Vjeux
- Tom Occhino
- [Michael Johnston](Creator of React Canvas)
- Ben Anderson
- Kevin Dangoor - Adobe Brackets
- Ian Obermiller
- David Nolen
- Huey Petersen
"Given the extremely tight coupling between the template and it's context (a controller/component), the concerns are the same, and splitting the DOM into a template is an arbitrary separation of technologies rather than a legit separation of concerns." - Hence in React, everything is a component. There is no template. Just define a
renderfunction.
"The React alternative is programming like you are throwing away your entire component and re-rendering it every time because it is simpler and easier to reason about. Event-based and data binding approaches frequently run into timing problems keeping track of which callback gets called first as well as make it difficult to understand how a small change in state will affect performance."
http://facebook.github.io/react/index.html
Mutable state and 2-way bindings made it hard to reason about.
React replaces an imperative mutating API with a declarative one that favors immutability.
Declarative -> Predictable -> Confidence -> Reliability
- Components rather than templates
- State is hard to manage
- DOM insertion is painful!
- No controller in React
- No template in React
- The single source of truth is all at the Component
- All the stuffs that live on the Ember controller live in React component
- Developed by Facebook
- Predictable Web Framework
- Expressive and modular
- Just the "V"
- Component ownership pattern (iOS-like?) - Top-level components, higher hierarchy tell children how they should render.
- Components can be stateful
- Encouraged 1-way data flow
- Highly performant
- Good practices of creating very very small components
- Re-render everything on every change
- Model states, not transitions
- Declarative programming
- Immediate mode rendering
React don't like 2-way data binding and template. It like one-way data flow and no template.
f(d) = v
f(d`) = v`
diff(v, v`) = changes
diff(v`, v) = undo # Go back in time, getting undo for free
d = data
v = virtual DOM
renderComponentToString() // Isomorphic applications
The initial HTML can be generated on the server. React handles the "view" but not with templates in the usual sense. React views are not dumb, they are "virtual DOM".
Using a difference algorithm to calculate the fewest number of steps required to render each state.
Render (and re-render) a view hierarchy to any sort of backend you want. It is DOM agnostic.
What makes UI so hard? State changing over time is evil. Model your UI as pure function.
- A small open-source app made with React and Rails-api
- Build with React
- Nice tutorial to start
- $19 book
- Master React - Another book
- React Primer
- Why React? (2013 articles)
- React Conf roundup
- A comprehensive guide to building apps with React
- Why React is awesome
- Awesome React
- 60fps mobile web
- Fixed Data Table
- What's so great about React
- React.js and ES6 classes
- Takeaways from React.js Conf 2015
- Tweet on Michael Jackson's react
- Why React Native matters
- React Future??
- React Components - Searchable database
- Presenting the most over-engineered blog ever - Pretty insightful
- React.js UI framework for hybrid mobile apps
- Pete Hunt: High performance functional programming with React and Meteor
- React: RESTful UI Rendering
- Reactive UI
- Building robust web apps with React
- Using react with browserify
- Example
- Gulpfile example for reactify
- Client side layout engines: React vs FruitMachine
- React vs Angular
- The question of having DOM in JavaScript
- Faster AngularJS rendering with ReactJS
- Improving AngularJS long list rendering performance using ReactJS
- Quickcoin nice React programming
- Why you might not need MVC with React.js
- Introduction to React.js
- Goya
- Rendering React Components on the server
- Om - too mind blow!
- Facebook's Immutable.js
- React.js and how does it fit in with everything else?
- Pete Hunt response to side-by-side AngularJS comparison
- Reactive Rails
- React for stupid people
- Do it myself or callback
- React.rb using Opal
- Some useful React utils
- Fresh on our radar: React Native
- Container components
- Glimmer in React
- React: Create maintainable, high-performance UI components - IBM developerWorks
- React tutorial and guide to the gotchas
- Implementing React.js in Swift?
- React is a terrible idea
- Component interop with React and Custom Element
- Mozilla and Web Component
- Real-time offline-ready web apps
- Exploring hotkeys and focus
- Best practices for building large React applications
- How I learned to stop worrying and love React
- 2 weird tricks that fix React
- Why React will force you to leave that comfort zone
- React 0.13 and Autobinding
- Baby's first reaction
- React, Part I: Building Reactive, Component-based UIs
- React from scratch
- Introduction to React.js diff algorithm
- Ask HN: React - Do you use it? Do you like it?
- Making performant React application
var gulp = require('gulp');
var browserify = require('gulp-browserify]');
var concat = require('gulp-concat');
gulp.task('scripts', function() {
gulp.src(['./src/main.js'])
.pipe(browserify({
transform: ['reactify']
}))
.pipe(concat('main.js'))
.pipe(gulp.dest('./build'));
});
- React Elements vs React Components vs Component Backing Instances
- React Component, Elements and Instances
- ReactNode, ReactElement, ReactFragment, ReactComponent
- Understanding the difference between React Elements and Components
- React (Virtual) DOM Terminology
While its true that
React.createElementis an instruction in a way, all it does is return a plain object (i.e. aReactElement). Passing thatReactElementtoReactDOM.renderis what actually creates theReactComponent. So, you can think of theReactElementas the instruction which is passed toReactDOM.render.
In v0.12, you no longer call it as React Component, but rather call it as ReactElement.
React is functional. Components are just like functions. They take in props and state and render HTML.
f(state, props) = UI Fragment
React.createElement('a', {href: 'http://host'}, 'Hello!')
// In JSX
<a href="http://host">Hello!</a>
// More examples
var MyComponent = React.createClass({
render() {}
});
var element = React.createElement(MyComponent);
// MyComponent is ReactComponent and you don't normally instantiate it
var component = new MyComponent(props); // never do thisWell-written components don't even need state, so:
f(props) = UI Fragment
This introduces the concept of idempotency and immutability.
React.renderComponent(); // Deprecated
React.render(); // Use this
React.isValidComponent(); // Deprecated
React.isValidElement(); // Use this
React.PropTypes.component // Deprecated
React.PropTypes.element // Use this
React.PropTypes.renderable // Deprecated
React.PropTypes.node // Use thisComponents are hierarchical. Without this you won't be able to represent HTML. To access the children:
this.props.children
Components are state machines. They have properties (determined by their parent) and state (which they can change themselves, perhaps based on user actions).
// Enable touch events for mobile devices
React.initializeTouchEvents(true);
- HTML entities
- Change and Its Detection in JavaScript Frameworks
- Face-off - Virtual DOM vs Incremental DOM vs Glimmer
- JSX: The other side of the coin
- A case for JSX
- WTF is JSX
- Static and Dynamic element
- Incremental DOM: What is it and why I should care?
Angular, Ember and Knockout put "JS" in your HTML. React puts "HTML" in your JS.
JSX is the key to React and it's purpose is to build composable tree/hierarchical UI.
Scale by composition - Build it small, compose it and scale it big.
Note: In v0.12, no more /** @jsx React.DOM */
<Component /> === React.createElement(Component)
const h = React.createElement;
h('ul', null, [
h('li', null, 'Foo'),
h('li', null, 'Bar'),
]);
const ul = React.createFactory('ul');
const li = React.createFactory('li');
ul(null, [
li(null, 'Foo')
li(null, 'Bar')
]);Solved cross-site scripting?
Allow to create composite component. Component is the proper separation of concern for us. Not the 3-legged stool of HTML, CSS and JavaScript. But a single JavaScript all the way. More composable?
class HelloMessage extends React.Component {
tick() {
this.setState({count: this.state.count + 1});
}
render() {
// No autowinding for tick() in v0.13.0
return <div onClick={this.tick.bind(this)}>Hello {this.props.name}</div>;
}
}
React.render(<HelloMessage name="mech" />, mountNode);
// Equivalent to this old ES3 module pattern?
function HellMessage(initialProps) {
return {
state: { value: initialProps.initialValue },
render: function() {
return <div>Hello {this.state.value}</div>;
}
};
}If you use JSX, displayName is generated for you.
// See https://dev.w3.org/html5/html-author/charref
// Won't work as it is encoded
<h1>{"More info »"}</h1>
// Use Unicode instead
<h1>{"More info \u00bb"}</h1>Using function is the best way to deal with conditionals. Or using variables.
// double-&&
<div className={this.state.isComplete && 'is-complete'}></div>
{isCorrect && <span className="response">{'\u2714'}</span>}getDefaultProps only ever called once for "all" instances. Do not do anything like Date.new inside getDefaultProps.
In Backbone, you are coding imperatively to specify when something changes, certain things should happen through it various view events setup.
In React, things are more declarative. You specify how your UI should look like at the render() and through props and states changes, the UI will change.
Declarative style require developer to think through at the start how the whole component UI look like and how they will interact.
--------- ---------
| Props | | State |
--------- ---------
+ +
----------
| Render |
----------
|
-------
| DOM |
-------
- Props - Constant and immutable. Likely fixed from the on-set. Supplies as component attributes like
<Hello name="mech" />. Try to usepropsas the source of truth where possible. - States - Can change. Mutable. You should design your component to not use state as much as possible. Try to keep as many of your components as possible stateless. Use state when you need to respond to user input, a server request or the passage of time. State should contain data that a component's event handlers may change to trigger a UI update (such as JSON request). Think of the UI as a state machine. By thinking of a UI as being in various states and rendering those states, it's easy to keep your UI consistent.
Props and states collectively represent the Model.
The final rendered DOM can have events. And once the events are triggered, the state can change which trigger another render.
If a component need to change and the cause of the change is the component's parent, then the parent can simply change the child's props and re-render.
If a component need to change due to some other component, then it need to use state.
Avoid states as much as possible. Instead push the event handling and state management up toward the top of your component hierarchy.
Note: Spread operator {...} deprecate this.transferPropsTo
A common pattern is to create several stateless components that just render data, and have a stateful component above them in the hierarchy that passes its state to its children via props. The stateful component encapsulates all of the interaction logic, while the stateless components take care of rendering data in a declarative way.
Combine simple functions to build more complicated ones. One way to manage complexity.
Just build simple interfaces. Makes it easier to predict what will happen.
How React enable nested component? By having a clear Input (properties) and Output (render() callback function), nested components is a very common outcome.
Certain operations that can be applied multiple times without changing the result beyond the initial application.
Easy to predict output for a given input. Immutability gets you idempotence for free.
You would use requestIdleCallback to make DOM changes on document fragment, but you would apply the DOM patches in the next requestAnimationFrame callback, not the idle callback.
Dirty-checking model can be slow. Virtual DOM is using tree, as we all know, tree can be fast.
DOM operation is very expensive! Because modifying the DOM will also apply and calculate CSS styles, layouts, etc.
- How to write your own Virtual DOM
- FRZR
- React-less Virtual DOM with Snabbdom
- Snabbdom
- virtual-dom
- Virtual DOM Benchmark
- A Virtual DOM and diffing algorithm
- Issues/3
- Virtual DOM and diffing algorithm
- Getting started with Virtual DOM
Re-render the entire application on every change.
- No observers
- No magical data binding
- No model dirty checking
- No
$apply()or$digest()
BUT: You can't just throw out the DOM and rebuild on every update? Lose form state, lost scroll position?
Cross-cutting concern like Logger, Subscribing? Just mix in methods.
- Create auto-complete search box
- react-flux-puzzle
- Mattermost
- Ryan Florence HYPE
- React tutorial
- 5 practical examples for learning React
- Firebase Vulcan - A chrome extension tool
- Using TDD with React
- Hacker News App
- React Magician
- Great.dj
- Building a multi-step registration form
- AirBnb
- Cosmos
- Pivotal CF
- pivotal-ui-react
- react-calendar
- react-tween-state
- Creating Chrome extensions with React
- Trying out React.js with the Marvel API
- Implementing the board game Go
- react-phonecat
- React and Adobe Brackets
- Building a board game with React.js
- Some example working with jQuery dialog
- Integrate with jQuery
- Optimizing Compiler: Reuse Constant Value Types like ReactElement
- JSX optimization in babel.js
- Implement Sideways Data Loading
- React/Flow/Type optimizations
- Pete Hunt - React vs The World
- Pete Hunt - Rethinking Best Practices
- Pete Hunt - Rethinking Best Practices (updated) 2013
- Functional Web Development
- Secret of the Virtual DOM
- Alt.Net Jan 2015
- Thinking in Components: Building Powerful UIs in React.js
- Learn React, Flux, and Flow - Seattle.js
- London React meetup - ES6 Modules and React with SystemJS
- E4E Developer Conf 2014 - Reactive, Component-based UIs with React
- All you need to know to get started with React
- Learn React, Flux, and Flow
- Netflix JavaScript Talks