Uncaught TypeError: Cannot read property 'props' of null

后端 未结 4 1531
猫巷女王i
猫巷女王i 2021-01-30 14:00
  • I have a react code
  • this code renders various panels in the UI.
  • when I click a tag, this function is called sportsCornerPanel()
  • but I am getting
4条回答
  •  梦毁少年i
    2021-01-30 14:41

    Declare a local variable in constructor for capturing context.

    I faced the same issue while using class className extends React.Component instead of createClass(). Create a variable in constructor to fix this.

    constructor(props) {
        super(props);
        self = this;
    }
    

    Use self.props instead of this.props everywhere!

提交回复
热议问题