So in short, I'm trying to use an array.map that can be called from one of two arrays depending on an if statement. A bit like so
class App extends Component { state = { foo: [ {number:"0"}, {number:"1"}, {number:"2"}, {number:"3"} ], bar: [ {number:"9"}, {number:"8"}, {number:"7"}, {number:"6"} ], fooBar: "foo" } test = () => { if(this.state.fooBar === "foo") { return this.state.foo } else { return this.state.bar } } onChangeFooBar = () = { this.setstate({fooBar: bar}) } render(){ <Button onClick={this.onChangeFooBar}>Set to bar</Button> <p>Here are some lines of text</p> {this.test.map(list => <p> {list.text} </p>)} } } However, it throws an error saying it's not a function. What is it I'm no getting here? I'm almost certain my issue is in the.test
returnstatement inside your render method.