Populate 2nd dropdown based on selection from 1st dropdown in React.Js

前端 未结 3 1133
刺人心
刺人心 2021-02-06 19:11

I am learning react and struggling to get a second dropdown to populate based on which option is clicked from first dropdown.

I have included my code below.

I

3条回答
  •  梦如初夏
    2021-02-06 19:41

    1. event handlers for e.g. onClick must be a function
    2. this.setState expects an object, which will be merged with the state so the part where you set selected in your state must be

      
      
    3. you use an undefined variable in your filter (selected), you have to use .filter(({tableName}) => tableName === this.state.selected) instead

提交回复
热议问题