This lesson will teach you the basics of setting properties in your React components. class App extends React.Component { render(){ let txt = this.props.txt return <h1>{txt}</h1> } } App.propTypes = { txt: React.PropTypes.string, cat: React.Pr…
When you're building your React components, you'll probably want to access child properties of the markup. In Angular, it is transcludion: <div> <ng-transculde></ng-transclude> </div> In React, it is: {this.props.children} It means…
When you're building your React components, you'll probably want to access child properties of the markup. Parent can read its children by accessing the special this.props.children prop.this.props.children is an opaque data structure: use the React.C…
State is used for properties on a component that will change, versus static properties that are passed in. This lesson will introduce you to taking input within your React components. Unlike props, which are meant to be passed into our component as s…
the transferPropsTo method lets you easily push properties into your components to easily customize attributes. From last two exmaples, we have BButton adn BHeart set up. var BButton = React.createClass({ render: function() { return ( <a className=&quo…
State is used for properties on a component that will change, versus static properties that are passed in. This lesson will introduce you to taking input within your React components. Properties vs. State When you think of properties, you should be t…
To make more composable React components, you can define common APIs for similar component types. import React from 'react'; import ReactDOM from 'react-dom'; export default class App extends React.Component{ constructor(){ super(); this.state = { re…
The React component lifecycle will allow you to update your components at runtime. This lesson will explore how to do that. import React from 'react'; import ReactDOM from 'react-dom'; export default class App extends React.Component { constructor(){…
The previous lesson introduced the React component lifecycle mounting and unmounting. In this lesson you will learn some simple uses for these hooks. import React from 'react'; import ReactDOM from 'react-dom'; class App extends React.Component { con…
React components have a lifecycle, and you are able to access specific phases of that lifecycle. This lesson will introduce mounting and unmounting of your React components. import React from 'react'; import ReactDOM from 'react-dom'; export default…
When you are using React components you need to be able to access specific references to individual components. This is done by defining a ref. Notice: 'ref' only works in class component, not in statless component. If we don't add "ref", three…
The owner-ownee relationship is used to designate a parent-child relationship with React components as it differs from the DOM relationship. import React from 'react'; export default class App extends React.Component { constructor(){ super(); //This…
In this lesson we'll setup a simple build process for converting our ES6 React components into ES5 using Babel and Webpack Install: npm i --save react react-dom npm i -D babel-loader babel-core babel-preset-es2015 babel-preset-react npm i -g babel we…
Mixins will allow you to apply behaviors to multiple React components. Components are the best way to reuse code in React, but sometimes very different components may share some common functionality. These are sometimes called cross-cutting concerns.…
The React component lifecycle will allow you to update your components at runtime. This lesson will explore how to do that. Updating: componentWillReceiveProps componentWillReceiveProps(object nextProps) Invoked when a component is receiving new prop…
The previous lesson introduced the React component lifecycle mounting and unmounting. In this lesson you will learn some simple uses for these hooks. <!doctype html> <html lang="en"> <head> <meta charset="UTF-8">…
React components have a lifecycle, and you are able to access specific phases of that lifecycle. This lesson will introduce mounting and unmounting of your React components. Mounting: componentWillMount Invoked once, both on the client and server, im…
To get the add-ons, use react-with-addons.js (and its minified counterpart) rather than the common react.js. <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/react.js"></script>--> <script src="http:…
When you are using React components you need to be able to access specific references to individual components. This is done by defining a ref. <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <…
The owner-ownee relationship is used to designate a parent-child relationship with React components as it differs from the DOM relationship. When one component renders another component, this is what React refers to as the "owner-ownee relationship,&…
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>React Lesson 0</title> </head> <body> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/react.…
"JSX transforms from an XML-like syntax into native JavaScript. XML elements and attributes are transformed into function calls and objects, respectively." Input: React.createClass({ render: function(){ var style = { backgroundColor: '#ccc', col…
we want to have the ability to write JSX and see the output live in the browser. <!doctype html> <html lang="en"> <head> <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="styles…
Since React is only interested in the V (view) of MVC, it plays well with other toolkits and frameworks. This includes AngularJS and D3. A app with React and D3.js: /** @jsx React.DOM */ var App = React.createClass({ getInitialState: function () { re…
It can be tedious to type out all the boilerplate needed to get the DOM and states in React to synchronize. Luckily, React provides a version of the toolkit with a selection of available addons. This lesson is going to dig into ReactLink, and how thi…
The JSX Transformer library is not recommended for production use. Instead, you'll probably want to precompile your JSX into JavaScript. Install: npm install react-tools -g Run: jsx dev build --no-cache-dir --watch //watch dev dir and compile js to b…
React JS Tutorials for Beginners - 1 - Getting Started https://www.youtube.com/watch?v=-AbaV3nrw6E&list=PL6gx4Cwl9DGBuKtLgPR_zWYnrwv-JllpA Downloads: https://facebook.github.io/react/downloads.html Sample code:https://github.com/buckyroberts/React-Bo…
先看一段代码能否秒懂很重要 这是app.js  全局js的入口 import React from 'react' import { render } from 'react-dom' import { Router, browserHistory } from 'react-router' import withExampleBasename from '../withExampleBasename' import './stubs/COURSES' const rootRoute = { c…
React lets you use "inline styles" to style your components; inline styles in React are just JavaScript objects that you can render in an element's style attribute. The properties of these style objects are just like the CSS property, but they a…
Introduction to Properties¶ Properties are an awesome way to define events and bind to them. Essentially, they produce events such that when an attribute of your object changes, all properties that reference that attribute are automatically updated.…