React.createElement(type, props, children)
Create a ReactElement
with the given component class, props
and children
.
var link = React.createElement('a', {href: '#'}, "Save")
var nav = React.createElement(MyNav, {flat: true}, link)
React.cloneElement(element, props, children)
Create a new ReactElement
, merging in new props
and children
.
ReactDOM.render(element, domNode)
Take a ReactElement
, and render it to a DOM node. E.g.
ReactDOM.render(
React.createElement('div'),
document.getElementById('container')
)
ReactDOM.findDOMNode(element)
Return the DOM node corresponding to the given element (after render
).
children
is automatically added to this.props
by React.createElement
.className
corresponds to the HTML class
attribute.htmlFor
corresponds to the HTML for
attribute.key
uniquely identifies a ReactElement
. Used with elements in arrays.ref
accepts a callback function which will be called:null
on unmount and when the passed in function changes.style
accepts an object of styles, instead of a string.Available under React.PropTypes
. Optionally append .isRequired
.
any
array
bool
element
func
node
number
object
string
instanceOf(constructor)
oneOf(['News', 'Photos'])
oneOfType([propType, propType])
var MyComponent = React.createClass({
displayName: 'MyComponent',
/* ... options and lifecycle methods ... */
render: function() {
return React.createElement( /* ... */ )
},
})
propTypes
object
mapping prop names to typesgetDefaultProps
function()
returning object
getInitialState
function()
returning object
componentWillMount
function()
componentDidMount
function()
componentWillReceiveProps
function(nextProps)
shouldComponentUpdate
function(nextProps, nextState)
-> bool
componentWillUpdate
function(nextProps, nextState)
componentDidUpdate
function(prevProps, prevState)
componentWillUnmount
function()
this
within class componentsref
callbacksReactElement
s.props
contains any props passed to React.createElement
state
contains state set by setState
and getInitialState
setState(changes)
applies the given changes to this.state
and re-rendersforceUpdate()
immediately re-renders the component to the DOM