Black screen after modifying index.js

前端 未结 1 1203
天涯浪人
天涯浪人 2020-12-11 09:48

I am following a tutorial online to learn how to use React.

The instructor made me create a project called albums and modify the content of index.

相关标签:
1条回答
  • 2020-12-11 10:01

    You need to define a background color for you application. You should also import View from react-native

    import { AppRegistry, Text, View } from "react-native";
    
    const App = () => {
     return (
       <View style={{backgroundColor: 'white', flex:1}}>
         <Text>Some Text</Text>
       </View>
      );
    };
    

    The reason that it is black is because the in the AppDelegate.m the rootView backgroundColor has been changed in version 0.58.0

    In prior versions it was

    rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
    

    It is now the following in 0.58.+

    rootView.backgroundColor = [UIColor blackColor];
    
    0 讨论(0)
提交回复
热议问题