Cannot read property x of ‘undefined’ with ternary condition?

The problem is here

      {selectedFilter === 0 ? renderAllTeamData() : renderTeamData()}

Here you are using === which is comparing against value and type but you set the currentTarget.value which is a string, so the comparison fails and moved to the else part

  <select
      value={selectedFilter}
      onChange={(e) => setFilter(e.currentTarget.value)}
    >

You can fix by changing it to compare by value like below

      {selectedFilter == 0 ? renderAllTeamData() : renderTeamData()}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top