0

this is my code:

{seasons.map(k => (
    <TabPanel key={k} className="list-episode">
         <Scrollbars style={{ height: this.state.screenSize }}>
             {arrEpisodes[k].map(i => (
                  <div key={i.ID} className="episode">

but, the line {arrEpisodes[k]... not work, why?

1
  • What happens when you say 'not work'? Commented Nov 10, 2018 at 4:51

1 Answer 1

3

Change

    {seasons.map(k => (
<TabPanel key={k} className="list-episode">
     <Scrollbars style={{ height: this.state.screenSize }}>
         {arrEpisodes[k].map(i => (
              <div key={i.ID} className="episode">

To

  {seasons.map((k, index)=> (
<TabPanel key={k.ID} className="list-episode">
     <Scrollbars style={{ height: this.state.screenSize }}>
         {arrEpisodes[index].map(i => (
              <div key={i.ID} className="episode">

The issue here is you are using data as index position to arrEpisodes array instead of index and that’s why it fails. You need to pass index of seasons array to arrEpisodes array. Also set id as key to TabPanel instead of Object I.e., k in your code

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.