From bd88dac4addea1d5f0abf7377dd73b58915f3239 Mon Sep 17 00:00:00 2001 From: Esa-Matti Suuronen Date: Tue, 8 Sep 2015 15:13:02 +0300 Subject: [PATCH] Query state in the render --- index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 91ee59a..bff439a 100644 --- a/index.js +++ b/index.js @@ -27,19 +27,19 @@ function reducer(state=[], action) { class Item extends React.Component { render() { - console.log("Item render: " + this.props.value); + console.log("Item render: ", this.props.index, this.props.numbers); return ( - {this.props.value} + hmm {this.props.numbers[this.props.index].foo.bar} ); } } Item.propTypes = { - value: React.PropTypes.number.isRequired + numbers: React.PropTypes.array.isRequired, + index: React.PropTypes.number.isRequired }; Item = connect((state, componentProps) => { - console.log("Selecting index " + componentProps.index, state[componentProps.index]); - return {value: state[componentProps.index].foo.bar} + return {numbers: state}; })(Item); class App extends React.Component {