React: “this” is undefined inside a component function

前端 未结 10 2241
春和景丽
春和景丽 2020-11-22 04:59
class PlayerControls extends React.Component {
  constructor(props) {
    super(props)

    this.state = {
      loopActive: false,
      shuffleActive: false,
    }         


        
10条回答
  •  Happy的楠姐
    2020-11-22 05:49

    in my case this was the solution = () => {}

    methodName = (params) => {
    //your code here with this.something
    }
    

提交回复
热议问题