Solution 1 :
Change your code to this:
import 'react-native-gesture-handler';
import {NavigationContainer} from '@react-navigation/native';
import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
} from 'react-native';
import {
Header,
LearnMoreLinks,
Colors,
DebugInstructions,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
const App: () => React$Node = () => {
return (
<>
<StatusBar barStyle="dark-content" />
<SafeAreaView>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={styles.scrollView}>
<Header />
{global.HermesInternal == null ? null : (
<View style={styles.engine}>
<Text style={styles.footer}>Engine: Hermes</Text>
</View>
)}
<View style={styles.body}>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Step One</Text>
<Text style={styles.sectionDescription}>
Edit <Text style={styles.highlight}>App.js</Text> to change this
screen and then come back to see your edits.
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>See Your Changes</Text>
<Text style={styles.sectionDescription}>
<ReloadInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Debug</Text>
<Text style={styles.sectionDescription}>
<DebugInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Learn More</Text>
<Text style={styles.sectionDescription}>
Read the docs to discover what to do next!
</Text>
</View>
<LearnMoreLinks />
</View>
</ScrollView>
</SafeAreaView>
</>
);
};
const styles = StyleSheet.create({
scrollView: {
backgroundColor: Colors.lighter,
},
engine: {
position: 'absolute',
right: 0,
},
body: {
backgroundColor: Colors.white,
},
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
color: Colors.black,
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
color: Colors.dark,
},
highlight: {
fontWeight: '700',
},
footer: {
color: Colors.dark,
fontSize: 12,
fontWeight: '600',
padding: 4,
paddingRight: 12,
textAlign: 'right',
},
});
export default App;
You had defined your App
component twice. And you also had some duplicate/contradicting imports.
Problem :
I’m currently building my first app using react-native. As I’m trying to run the simulator for both, IOS and Android, I run into errors. When I try running the simulator for IOS, using ‘npm run ios’, it runs the simulator successfully, but when I try to make changes in the App.js, they don’t appear in the simulator menu…I tried restarting the simulator several times but it didn’t work, I’m also not able to use commands within the simulator, such as ‘cmd+R’ to reload, even if there is no error message.
When It comes to Android, I can’t even run the simulator (using ‘npm run android’) and I always run into the following error message:
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected]
android:react-native run-android
npm ERR! Exit status 1 npm ERR!
npm ERR! Failed at the [email protected] android script. npm ERR! This is
probably not a problem with npm. There is likely additional logging
output above.npm ERR! A complete log of this run can be found in: npm ERR!
/Users/maurice/.npm/_logs/2020-07-13T08_19_29_328Z-debug.log
Maurices-MacBook-Air:myApp maurice$
Here’s my App.js:
/** * Sample React Native App *
https://github.com/facebook/react-native * * @format * @flow
strict-local */
import 'react-native-gesture-handler';
import 'react-native-gesture-handler';
import * as React from 'react';
import {NavigationContainer} from '@react-navigation/native';
const App = () => {
return (
<NavigationContainer>{/* Rest of your app code */}</NavigationContainer>
);
};
export default App;
import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
} from 'react-native';
import {
Header,
LearnMoreLinks,
Colors,
DebugInstructions,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
const App: () => React$Node = () => {
return (
<>
<StatusBar barStyle="dark-content" />
<SafeAreaView>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={styles.scrollView}>
<Header />
{global.HermesInternal == null ? null : (
<View style={styles.engine}>
<Text style={styles.footer}>Engine: Hermes</Text>
</View>
)}
<View style={styles.body}>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Step One</Text>
<Text style={styles.sectionDescription}>
Edit <Text style={styles.highlight}>App.js</Text> to change this
screen and then come back to see your edits.
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>See Your Changes</Text>
<Text style={styles.sectionDescription}>
<ReloadInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Debug</Text>
<Text style={styles.sectionDescription}>
<DebugInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Learn More</Text>
<Text style={styles.sectionDescription}>
Read the docs to discover what to do next!
</Text>
</View>
<LearnMoreLinks />
</View>
</ScrollView>
</SafeAreaView>
</>
);
};
const styles = StyleSheet.create({
scrollView: {
backgroundColor: Colors.lighter,
},
engine: {
position: 'absolute',
right: 0,
},
body: {
backgroundColor: Colors.white,
},
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
color: Colors.black,
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
color: Colors.dark,
},
highlight: {
fontWeight: '700',
},
footer: {
color: Colors.dark,
fontSize: 12,
fontWeight: '600',
padding: 4,
paddingRight: 12,
textAlign: 'right',
},
});
export default App;
I can’t fix the problem and hope for any help.
Regards,
Maurice
Comments
Comment posted by Mauri Mark
Apparently that doesn’t work, trying to run the Android emulator leads into the same problem. Running the IOS Simulator leads into another new problem, which displays an error message within the simulator. I link a screenshot below. Thanks for the answer, Maurice
Comment posted by Bas van der Linden
The error in the image you posted means that you haven’t installed
Comment posted by Mauri Mark
I installed react-native-gesture-handler, but when I did this and tried to run the IOS Simulator, I got the same problem as I get with running the Android Emulator, which is that I run into the error message, which I linked in my first post.
Comment posted by Bas van der Linden
In case of iOS make sure you have installed the
Comment posted by Mauri Mark
CocoaPods are installed and restarting also doesn’t work. There are no steps to solve the problem within the error message, but I found something interesting, which maybe could help solving the problem. The error message says: warning: The iOS Simulator deployment target ‘IPHONEOS_DEPLOYMENT_TARGET’ is set to 5.0, but the range of supported deployment target versions is 8.0 to 13.5.99. (in target ‘CocoaAsyncSocket’ from project ‘Pods’)