I want to access this inside an array. Specifically,
this.props.categoryOpen.toString()
throws an error when used as follows.
https://codesandbox.io/s/23l3p906zimport React, { Component } from "react";
class Child extends Component {
render() {
return (
<div>
{this.props.categoryOpen.toString()}
{this.rows.map(row => (
<div>
{row.cells.map(cell => (
<div key={cell.label}>
{cell.label}: {cell.data}
</div>
))}
</div>
))}
</div>
);
}
rows = [
{
cells: [
{
label: "Cell A",
data: {this.props.categoryOpen.toString()}, // breaks
//data: "Foo" // works
},
{
label: "Cell B",
data: "Bar"
}
]
}
];
}
export default Child;
An arrow function also throws an error.
rows = () => [...
How can I access this?
