From 7149218fa4ae96f2a4071b4c8226563c97bca198 Mon Sep 17 00:00:00 2001
From: Travis CI
Before you build components with an API similar to this, consider if there are cleaner alternatives. For example, you can pass entire React component as props if you'd like to.
If contextTypes is defined within a component, the following lifecycle methods will receive an additional parameter, the context object:
void componentWillReceiveProps(
- object nextProps, object nextContext
-)
+If contextTypes is defined within a component, the following lifecycle methods will receive an additional parameter, the context object:
-boolean shouldComponentUpdate(
- object nextProps, object nextState, object nextContext
-)
-
-void componentWillUpdate(
- object nextProps, object nextState, object nextContext
-)
-
-void componentDidUpdate(
- object prevProps, object prevState, object prevContext
-)
-constructor(props, context)componentWillReceiveProps(nextProps, nextContext)shouldComponentUpdate(nextProps, nextState, nextContext)componentWillUpdate(nextProps, nextState, nextContext)componentDidUpdate(prevProps, prevState, prevContext)Stateless functional components are also able to reference context if contextTypes is defined as a property of the function. The following code shows a Button component written as a stateless functional component.
const Button = ({children}, context) =>
<button style={{background: context.color}}>