反应,不兼容的覆盖,应该有签名

时间:2018-01-24 09:36:49

标签: javascript reactjs react-native

当我使用shouldComponentUpdate函数时, webStorm发出警告'不兼容的覆盖,应该有签名....', 但代码运作良好。我是否想念一些我没有意识到的错误?

代码 shouldComponentUpdate(nextProps){ if(nextProps.TAC.length === 8 && nextProps.TAC !== this.props.TAC){ fetch(`http://${host}:3001/searchHistory`,{ method:'post', headers:{'Content-Type':'application/json'}, credentials:'include', body:JSON.stringify({TAC:Number(nextProps.TAC)}) }).then(res=>res.json()) .then(result=>{ if(result){ Alert.alert('提示','该信息为今天录入/已经缓存',[ {text:'取消', onPress:()=>this.props.toggleStatus(false)}, {text:'查看',onPress:()=>this.props.toggleStatus(true)}, ],{ cancelable:false }) } }); } return nextProps !== this.props }

Code

1 个答案:

答案 0 :(得分:3)

只需添加缺少的参数nextState,WebStorm就会很高兴

shouldComponentUpdate(nextProps, nextState)

Signature”表示在组件扩展的React.Component类或React.PureComponent中定义的函数参数的数量和类型。

相关问题