diff --git a/components/AltContainer.js b/components/AltContainer.js index f529feae..1103834e 100644 --- a/components/AltContainer.js +++ b/components/AltContainer.js @@ -160,6 +160,12 @@ var AltContainer = React.createClass({ ) }, + shouldComponentUpdate: function () { + return this.props.shouldComponentUpdate + ? this.props.shouldComponentUpdate(this.getProps()) + : true + }, + render: function () { var children = this.props.children diff --git a/docs/components/altContainer.md b/docs/components/altContainer.md index 321598dc..2a1cc2d1 100644 --- a/docs/components/altContainer.md +++ b/docs/components/altContainer.md @@ -197,3 +197,19 @@ const flux = new Flux(); ``` Header, Body, and Footer will have the `flux` context passed down. + +## `shouldComponentUpdate` + +`shouldComponentUpdate` prop allows you to fine-tune your performance needs for AltContainer only rendering when absolutely necessary. + +This is a function that gets called with the props that your children will receive. You return a boolean depending on if you wish to re-render or not. + +```js + false}> +
+ +