I have a Keypad component, each time I press a button it should add that button's value to an array:
var keys = this.props.keys.map(function(k, index){
return (
<tr className="button-row" key={index}>
<td>
<button
className="keypad-buttons"
onClick={self.props.number.bind(null, k.k)}
>{k.k}</button>
</td>
</tr>
)
})
In my main App component I have a method for adding the numbers entered by Keypad so that I can map over them and display them in the textArea of
my Screen component. Here is the relevant part of App:
getInitialState: function(){
return {numbers: []}
},
addNumber: function(num){
var number = [
{
n: num
}
]
this.setState({
numbers: this.state.numbers.concat(number)
})
},
In Screen component I am trying to map over the props received from App like this:
var pinNumbers = this.props.pin.map(function(num, index){
return (
<span key={index}>{num.n}</span>
)
}).join(' ')
And then display that in textArea by doing value={pinNumbers}. So if I type 1 2 3 on the keypad, it should map over the array of objects and display each of those values (123) in the textArea of my Screen component; instead, it displays [object Object] and I cannot figure out why. Here is a demo: http://codepen.io/p-adams/pen/PzZWJJ