ReactJS承诺-_this.setExitAnimation未定义

时间:2019-01-29 12:39:24

标签: javascript reactjs promise

我将使用promise来设置动画,我试图创建一个promise'链来释放动画的新价值。 但是控制台返回我:

  

_this.setExitAnimation未定义   这是我的reactJS代码段:

/***** HERE TRIGGER THE setAnimation's PROCESS THEN INJECT 
UPDATED ANIATION IN COMPONENT *****/
textAnimation=()=>{            

    // CALL THE PROMISE'S CHAIN
      this.setState({elementType:"text"}, 
        () => this.routeAnimationPosition
          .then((anim) => { 
            console.log("promise resolved: ", anim)
            // set new animations
        this.setState({firstLineAnimation:anim}, 
          () =>     console.log("after setState textAnimation: ", this.state.textAnimation)
          )
{...}

/***** HERE START THE PROMISE'S CHAIN TO UPDATE ANIMATION'S NAME *****/

routeAnimationPosition= new Promise((resolve, reject)=>{ 
  console.log("in routeAnimationPosition")
  if(this.state.exitLoop){ 
    this.setExitAnimation.then((anim)=> resolve(anim)); 
  }else{ 
    this.setEnterAnimation.then((anim)=> resolve(anim));
  }  
})

setEnterAnimation=new Promise((resolve, reject)=>{ 
  console.log("in setEnterAnimation")
  if(this.state.elementType ==="text"){
    if(this.state.currentView % 2 === 0){ 
      this.setState({textAnimation:enterDownAnimation});
      resolve(enterDownAnimation);
{...}

我不知道出了什么问题,在我看来我的动画制作过程很公平, 任何提示都会很棒, 谢谢

0 个答案:

没有答案