Issue with React Native Simulator on IOS and Android

Currently in the process of constructing my initial app using react-native. I encountered issues while attempting to run the simulator for both IOS and Android. When trying to launch the simulator for IOS with 'npm run ios', it operates successfully, but any modifications made in the App.js do not reflect in the simulator menu...Restarting the simulator multiple times did not resolve this issue, and commands like 'cmd+R' to reload within the simulator are also unresponsive despite no error messages being displayed. Regarding Android, I face difficulties even initiating the simulator (by using 'npm run android'), as I consistently receive 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 an excerpt from 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;

If anyone has suggestions on resolving these problems, I would greatly appreciate the assistance. Best regards, Maurice

Answer №1

To optimize your code, make the following adjustments:

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;

The App component was defined twice and there were some conflicting imports which have been resolved now.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

show a list of checkboxes that have been selected using JavaScript

I have a group of Checkbox options for 7 Days all with the same name of "sessionDays." I have used the following code to count the number of checked checkboxes: var totalDays = document.querySelectorAll('.sessionDays input[type="checkbox"]:checked&a ...

Having trouble retrieving information from the local API in React-Native

Currently, I have a web application built using React and an API developed in Laravel. Now, I am planning to create a mobile app that will also utilize the same API. However, I'm encountering an issue where I cannot fetch data due to receiving the err ...

Save a collection of controller instances within a separate controller in AngularJS

I am in need of an angular example where one controller wraps another. For instance, I am looking to divide some logic between EndpointListController and EndpointController. EndpointListController will handle retrieving data from storage, along with funct ...

Utilize the Bootstrap column push-pull feature on the mobile version of

https://i.stack.imgur.com/yTBIt.png When viewing the desktop version, div A is displayed at the top of the page. However, I would like to move it to the bottom when viewing on a mobile device (col-xs). I have attempted to solve this issue myself without s ...

Develop a jQuery dialog box without assigning an ID

I need help with jQuery to create a dialog that opens and then populates with values. When I tried to create the dialog using jQuery, it kept using old values because the div already existed on the page. I want to create a new instance of the dialog usin ...

Is it possible to generate a DOM Document using an encoded UTF-8 byte array?

In my current scenario: I am working with a method that takes in a byte array. This specific array is encoded using UTF-8 and originally contained an XML message. My goal is to reconstruct this message using a DOM parser. I understand that it is possible t ...

Nuxt.JS is not rendering blocks in the way that I require

I am currently developing a nuxt.js SSR web application and encountered an unusual issue. <div class="container" @mouseenter="hovered = true" @mouseleave="hovered = false"> <transition name="fade"> <div class="class1" v-show="!hovered ...

Display or conceal polygons according to the contents visible on the screen

Currently, I am facing an issue with the Google Maps on my Android app. When loading multiple polygons onto the map, it causes a significant lag. Even though my map is zoomed in, many of the polygons are not visible on the screen but still contribute to th ...

There are occasions when Flutter local notifications fail to function properly in the app's release version

I am having trouble with the periodicallyShow() method in flutter_local_notification. Sometimes the notification does not show up, but it works fine in debug mode. I have tried various solutions like using 'flutter build apk --no-shrink', adding ...

The presence of onChange?: (ValueType, ActionMeta) => void with OptionType is not compatible

After updating to version v2.4.2, I keep encountering an error from flow regarding react-select. It seems that I am passing the correct types to the handle change, which expects an array with objects + OptionType accepting any string [string]: any. Can som ...

Is it possible to utilize jQuery's .wrap or .wrapInner to encase a variety of elements within them?

I am working with a HTML structure that looks like this: <section> <item> <ele class="blue" /> <ele class="green" /> <ele class="red" /> </item> <item> <ele class="blue" /> <ele ...

Discovering unique chain characters within a string and altering their color - a step-by-step guide

For example, I have a string such as: Numbers: [3] or Numbers: [213] Is it possible to identify and modify the color of the characters within the brackets [] and the numbers that follow it? ...

Set the Vue 3 Select-Option to automatically select the first option as the default choice

I am attempting to set the first select option as the default, so it shows up immediately when the page loads. I initially thought I could use something simple like index === 0 with v-bind:selected since it is a boolean attribute to select the first option ...

Clicking a button in jQuery to load the Pagemethods

<script type="text/javascript"> $(document).ready(function() { $('#loadbtn').click(function() { // can 't load opts = { title: 'ABCD', series: [{ ...

Are the DataTables rows functioning properly, or have they not been initialized?

After setting up my website with DataTables and retrieving data through its ajax service from a Java servlet backend, everything seemed to be working fine with the DOM. However, despite having all the data in place, I encountered issues with some of the fe ...

Is there a way to implement DnD functionality on a dynamically generated div element within an HTML page using Dojo

Is it possible to implement drag and drop functionality on dynamically generated div elements using Dojo? I have experimented with various methods to incorporate this feature. Below is a snippet of my code: var inputdiv = document.createElement('div& ...

The issue persists with the addEventListener function not working multiple times

My issue is that the addEventListener function is only working for the 'scroll' event and not for 'addMoreFields' or 'removeFields'. If I move the scroll section down, then it works for 'addMoreFields' and 'remo ...

I am interested in incorporating the ability to select and scroll the window without needing to interact with the scroll bar by

Imagine a visitor wanting to highlight all the information on a webpage. They choose to start dragging their cursor towards the bottom of the window. How can we enable the webpage to smoothly scroll down as they do this? ...

How to Utilize Puppeteer for Redirecting Pages While Preserving Cache?

Currently, I am facing a challenge with my code in JavaScript that is responsible for opening a page and logging in. Once Puppeteer finishes the login process, I need it to redirect to another page on the same site without clearing the cache. I attempted ...

Error: 'require' is not recognized in index.html file for electron-forge application using the react template

After initiating an electron-forge app using the react template, I encountered an issue where the app only displayed a white screen. The developer console showed the error "Uncaught ReferenceError: require is not defined" at index.html:inline_0.js:2 electr ...