I'm following a tutorial online for React.js on controlled inputs and I am repeatedly getting the error
TypeError: Cannot read property 'map' of undefined
import CallRow from "./CallRow";
import React from "react";
class SearchPage extends React.Component {
constructor() {
super();
this.state = {
search: "Level Up"
};
}
updateSearch(event) {
this.setState({ search: event.target.value.substr(0, 20) });
}
render() {
return (
<div>
<ul>
{this.props.calls.map(call => (
<CallRow call={call} key={call.id} />
))}
</ul>
<input
type="text"
value={this.state.search}
onChange={this.updateSearch.bind(this)}
/>
</div>
);
}
}
export default SearchPage;
SearchPage. That code you share should help you and other people answer the following questions: 1) Did you providecallsas props to the component; 2) If you did, did you check that it was notundefined? - Imran Ariffin