Reactjs 工厂不在本地工作

Reactjs 工厂不在本地工作,reactjs,react-native,floating-action-button,Reactjs,React Native,Floating Action Button,我使用上述代码是为了在我的项目中添加一个FAB。但我有一个错误: 正文:{type:TransformError,代码段:3 |构造函数{ 4 |本州 这似乎是NativeBase给出的示例代码中的错误。为了更正错误,请在构造函数中添加super;,如下所示 import React, { Component } from 'react'; import { Container, Header, View, Button, Icon, Fab } from 'native-base'; expo

我使用上述代码是为了在我的项目中添加一个FAB。但我有一个错误:

正文:{type:TransformError,代码段:3 |构造函数{ 4 |本州


这似乎是NativeBase给出的示例代码中的错误。为了更正错误,请在构造函数中添加super;,如下所示

import React, { Component } from 'react';
import { Container, Header, View, Button, Icon, Fab } from 'native-base';
export default class FABExample extends Component {
  constructor() {
    this.state = {
      active: 'true'
    };
  }
  render() {
    return (  
      <Container>
        <Header />
        <View style={{ flex: 1 }}>
          <Fab
            active={this.state.active}
            direction="up"
            containerStyle={{ }}
            style={{ backgroundColor: '#5067FF' }}
            position="bottomRight"
            onPress={() => this.setState({ active: !this.state.active })}>
            <Icon name="share" />
            <Button style={{ backgroundColor: '#34A34F' }}>
              <Icon name="logo-whatsapp" />
            </Button>
            <Button style={{ backgroundColor: '#3B5998' }}>
              <Icon name="logo-facebook" />
            </Button>
            <Button disabled style={{ backgroundColor: '#DD5144' }}>
              <Icon name="mail" />
            </Button>
          </Fab>
        </View>
      </Container>
    );
  }
}

您可以参考本文了解更多详细信息,了解为什么构造函数需要在访问“this”之前调用super

addsuper;before this.state{…}谢谢。现在错误消失了。但是默认情况下会显示子图标。你能告诉我子图标是什么意思吗?如果你指的是facebook,whatsapp共享图标,我可以看到你共享的代码片段中写的代码。你能澄清一下吗?
constructor() {
  super();
  this.state = {
    active: 'true'
  };
}