0
点赞
收藏
分享

微信扫一扫

React的各种bug及分析

WikongGuan 2023-12-27 阅读 38

Parsing error: Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead.

脚手架修饰器的问题:

我一般碰到这个问题,就直接把导出代码写到外面。

@connect(state => ({
  isloading: state.error.isloading,
}))
 class TriggerException extends PureComponent {
  state = {
    isloading: false,
  };

  triggerError = code => {
    this.setState({
      isloading: true,
    });
    const { dispatch } = this.props;
    dispatch({
      type: 'error/query',
      payload: {
        code,
      },
    });
  };

  render() {
    const { isloading } = this.state;
    return (
      <Card>
        <Spin spinning={isloading} wrapperClassName={styles.trigger}>
          <Button type="danger" onClick={() => this.triggerError(401)}>
            触发401
          </Button>
        </Spin>
      </Card>
    );
  }
}

export default TriggerException //把导出代码写到这里

不过网上看还有其她的操作。
Using the export keyword between a decorator and a class is not allowed(create-react-app修饰器的问题 github上这个问题的解决

Error:JSON value '<null>' of type NSNull cannot be converted to NSString

出这个问题是我们不能把值null转为string,所以报错了,处理也非常简单,只需要判断是否为空,就可以搞定,我们

经常发生这个错误的地方就是:

<Image style={styles.image_style} source={{uri:avatar}}></Image>


举报

相关推荐

0 条评论