Answer the question
In order to leave comments, you need to log in
In ReactJs, when rendering a matrix based on a 2d array, the function is not visible for the cell element, how to deal with this?
There is a suspicion that due to 2 return-s, the updateMatrix function is not visible to the cell element, how to deal with this?
var Matrix = React.createClass({
getInitialState: function(){
return {
arr: A
};
},
updateMatrix: function(arr){
this.setState({
arr: arr
});
},
render: function(){
return <table className="Matrix">
<tbody>
{this.props.arr.map(function(row, i){
return (
<tr key={i}>
{row.map(function(cell, j){
return <td key={j}><Cell val={cell} action={this.updateMatrix} /></td>;
})}
</tr>
);
})}
</tbody>
</table>
;}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question