React native 视图样式在本机中不起作用

React native 视图样式在本机中不起作用,react-native,React Native,我是新来的, 在我的代码中使用constmain=()=>{..} 但是,当我更改为导出默认类Main extends React.Component{..}时,会出现问题,例如视图中的样式不起作用,但出现错误,“样式中预期的样式” 拍摄: im使用的是react native的新版本您缺少render()方法,而return()方法应该是 例: 导出默认类LotsOfStyles扩展组件{ render(){ 返回( 只是红色 只是蓝色的 蓝色,然后是红色 红色,然后是蓝色 ); } }

我是新来的, 在我的代码中使用
constmain=()=>{..}

但是,当我更改为导出默认类Main extends React.Component{..}时,会出现问题,例如视图中的样式不起作用,但出现错误
,“样式中预期的样式”

拍摄:

im使用的是react native的新版本

您缺少render()方法,而return()方法应该是

例:

导出默认类LotsOfStyles扩展组件{
render(){
返回(
只是红色
只是蓝色的
蓝色,然后是红色
红色,然后是蓝色
);
}
}

中,您缺少render()方法,而return()方法应该在该方法中

例:

导出默认类LotsOfStyles扩展组件{
render(){
返回(
只是红色
只是蓝色的
蓝色,然后是红色
红色,然后是蓝色
);
}
}

export default class LotsOfStyles extends Component {
  render() {
    return (
      <View>
        <Text style={styles.red}>just red</Text>
        <Text style={styles.bigBlue}>just bigBlue</Text>
        <Text style={[styles.bigBlue, styles.red]}>bigBlue, then red</Text>
        <Text style={[styles.red, styles.bigBlue]}>red, then bigBlue</Text>
      </View>
    );
  }
}