react生命周期里面的componentwillreceiveProps

可以在该生命周期里面的一个判断里面进行return来中止该判断后面代码的执行吗?

阅读 1.4k
1 个回答

你可以中断该函数体内后续的其他代码的执行,比如:

componentWillReceiveProps(){
  if(true) return;
  console.log(123); // 这里将不会执行
}
推荐问题