TypeError: Cannot read property 'map' of undefined

return (

            <div className="TrackList">


                    this.props.tracks.map(track => {

                        return (













return (



    <a href="http://loaclhost:3000">




  <div className="App">

    <SerachBar onSearch={this.search} />

    <div className="App-playlist">

      <SerachResults serachResults={this.state.serachResults} onAdd={this.doThese} />

      <Playlist playlistTracks={this.state.playlistTracks} onNameChange={this.updatePlaylistName} onRemove={this.removetrack} onSave={this.savePlaylist} />





return (

        <div className="Playlist">

            <input onChange={this.handleNameChange} defaultValue={' New Palylist '} />




                onRemove={this.props.onRemove} />

            <button className="Playlist-save" onClick={this.props.onSave}> Save To Spotify </button>



render() {

    return (

        <div className="SearchResults">


            <TrackList tracks = {this.props.serachResults} onAdd={this.props.onAdd}/>




Hello, you haven’t posted enough of the code to fully uncover what’s going on, but we can say with certainty that this is the line throwing the error:

What this means is that at some point in your code, this.props.tracks was set to undefined instead of an array (even an empty array would be fine). This could happen because you didn’t pass the property to the component correctly so undefined is the default or the value undefined was sent from another component.

Here’s an example of things going wrong:

Notice that from PlayList.js, you’re sending it on track, so TrackList would need to use this.props.track instead of this.props.tracks, but from SearchResults.js you’re trying to send it on tracks

Another thing that I’ve noticed is that the spelling of “search” is inconsistent. You wrote that the filename was SeachResults, but then you use a component named SerachResults. Also a SerachBar and this.state.serachResults. You didn’t include the code where you’re setting the initial state, so I don’t know if that’s what you called it or not. As long as you’re consistent, then the spelling won’t really matter, but you should double check that you use it properly in all other areas because it could be another issue.

I hope this helps get you on the right track


You are incredible Man ,Thank You
I knew where the problem is , Now , its Working

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.