Communicate Between Components

For parent-child communication, simply pass props. For child-parent

2016-06-23 03:31:32
Expose Component Functions

There's another (uncommon) way of communicating between components: simply expose a method

2016-06-23 03:31:57
If-Else in JSX

if-else statements don't work inside JSX. This is because JSX is just syntactic sugar for function calls and object construction. Take this basic example:

2016-06-23 03:32:02
Value of null for Controlled Input

Specifying the value prop on a controlled component prevents the user from changing the input unless

2016-06-23 03:32:37
Inline Styles

In React, inline styles are not specified as a string. Instead they are specified with an object whose key is the camelCased version of the style name, and whose value is the

2016-06-23 03:32:02
Dangerously Set innerHTML

Improper use of the innerHTML can open you up to a cross-site scripting

2016-06-23 03:31:52
Maximum Number of JSX Root Nodes

Currently, in a component's render, you can only return one node; if you have, say, a list of divs to return, you must wrap your components within

2016-06-23 03:32:05
False in JSX

Here's how false renders in different situations: Renders as id="false":

2016-06-23 03:31:58
this.props.children undefined

You can't access the children of your component through this.props.children. this.props.children designates the children being passed onto

2016-06-23 03:32:32
Props in getInitialState Is an Anti-Pattern

This isn't really a React-specific tip, as such anti-patterns often occur in code in general; in this case, React simply points them out more clearly.

2016-06-23 03:32:06