componentDidMount阻止动作分派器

时间:2020-06-26 16:16:29

标签: javascript reactjs

请让我知道是否需要更多详细信息以提供帮助。

我有以下class component(只是开头)-我称它​​为组件A

class Hello extends Component {
  constructor(props) {
    super(props)

    this.rawSet = curry(this.rawSet.bind(this))
    this.set = curry(this.set.bind(this))
    this.update = curry(this.update.bind(this))
    this.get = this.get.bind(this)
    this.value = this.value.bind(this)
    this.safeValue = this.safeValue.bind(this)
    this.has = this.has.bind(this)
    this.delete = this.delete.bind(this)
    this.conditional = this.conditional.bind(this)

    const scope = props.scope || {}
    this.commit = scope.commit || this.commit.bind(this)
    this.pull = scope.pull || this.pull.bind(this)
    this.scopePath = scope.scopePath

    if (!props.scope) {
      this.state = this.describe(props.entity, props.schema)
    }
  }

  componentDidMount() {
    this.props.getEntity && this.props.getEntity()
  }

然后我从第一个类扩展了另一个类组件-我将其称为组件B

class Bye extends Hello {
  constructor(props) {
    super(props)
    this.can = this.can.bind(this)
    this.cannot = (...args) => !this.can(...args)
    this.save = this.save.bind(this)
    this.savePicture = this.savePicture.bind(this)
    this.doSave = this.doSave.bind(this)
  } 

  componentDidMount(){
    console.log('Bye')
  }

现在,B中有一些动作调度程序。但是,我注意到,这些动作绝不会仅仅因为在B中定义了componentDidMount()而被调度。如果我将其完全删除,则调度员可以正常工作。

componentDidMount()的{​​{1}}与B的{​​{1}}之间是否存在引起此问题的冲突?

谢谢!

0 个答案:

没有答案