ESLint Must use destructuring state assignment

后端 未结 1 624
灰色年华
灰色年华 2020-12-07 00:09

I am getting ESlint error for the following line this.state.items.map(item => (

The error is Must use destructuring state assignment

1条回答
  •  自闭症患者
    2020-12-07 00:53

    That's called:

    Enforce consistent usage of destructuring assignment of props, state, and context (react/destructuring-assignment)

    More details are available here: destructuring-assignment

    In order to make that warning/error disappear, you could do like this:

          ...
          const { items }= this.state;
          ...
          {
            items.map(item => (
              
    { item.links.map(thing => ( {thing.link.text} )) }
    )) }

    0 讨论(0)
提交回复
热议问题