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

前端 未结 3 1136
刺人心
刺人心 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:44

    Some things to look at:

    The syntax in your call to setState in your event handler looks incorrect.

    You also make try to reference this.state.selected in your .filter condition without the path to the variable (this.state)


    Suggested solution(s):

    // The .setState method expects an object to be passed to it rather
    // than an expression that mutates the state directly
    
    // Pass it an object containing the properties you want to change,
    // ensure your use colon (':') rather than equals sign ('=') to set property:
    ))
    }
    
    

提交回复
热议问题