Confused about how to navigate using NavigatorIOS in React Native

My application is quite simple:

import React, { Component } from 'react';
import Landing from './App/pages/landing.js';

import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  TouchableOpacity,
  NavigatorIOS
} from 'react-native';

class twitterQue extends Component {

  _enter() {
    console.log('Hey Girl');
  }

  render() {
    return (
      <NavigatorIOS
        initialRoute={{
          component: Landing,
          title: 'Welcome!',
          passProps: {},
        }}
      />
    );
  }
}

AppRegistry.registerComponent('twitterQue', () => twitterQue);

Next up is the landing component:

import React, { Component } from 'react';
import Button from '../components/button/buttons.js';

import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  TouchableOpacity
} from 'react-native';

class Landing extends Component {

  _enter() {
    console.log('Hey Girl');
  }

  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Twitter Que
        </Text>
        <Button type={"primary"} buttonWidth={240} onPress={() => this._enter()}>Que Up Some Tweets!</Button>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
});

AppRegistry.registerComponent('Landing', () => Landing);

module.exports = Landing;

Everything seems fine. No rendering on the page and no errors. The app loads, showing "Welcome!" as the title but the (Landing) component does not display. What could I be missing?

If I move everything from Landing's render into index.js's render, it works. Am I misinterpreting the documentation?

Answer №1

To enhance the appearance of NavigatorIOS, consider incorporating style={{flex:1}}:

<NavigatorIOS
    style={{flex:1}}
    initialRoute={{
      component: Landing,
      title: 'Get Started!',
      passProps: {},
    }}
  />

By default, NavigatorIOS does not come with predefined styles. This implies that there is no pre-set width or height specified. If you omit specifying a width, height, or flex value, it may not be visible in your view.

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

I'm seeking assistance in understanding the malfunction of this particular function

I am struggling to create a basic function that is supposed to check whether a value is a number and not greater than 100. I'm confused as to why it's not working. Can someone explain if mixing jQuery and JavaScript is causing the issue? $(' ...

Utilizing a CAKeyframeAnimation to generate a animated fireball effect similar to the one

I'm attempting to create an animation that mimics the fireball effect seen around the Siri microphone icon while it's searching for information. Essentially, it involves an object moving in a circular pattern and leaving a visible trail behind. ...

Is there a way to rotate the custom marker icon in vue2-google-map?

After reading the documentation, I discovered that using path is the only way to rotate the marker. In an attempt to customize my marker, I created my own PNG image. However, I have been unsuccessful in overriding the CSS of the marker. I even tried to ov ...

Error encountered while trying to display content in the rendering area

const Pages = () => { return ( <> <Box display="flex"> {window.location.pathname === "/profile" ? undefined : <Sidebar />} <Box flex={3}> <Navbar /> <Routes> {/* Cont ...

Managing several gestures at once

I have two subviews view1 and view2. Within my parentview, I have added both LongPress and Pan gestures. When performing a long press on view1, a draggable view with popup animation will appear just below the finger, allowing for dragging of the dragView t ...

History.replaceState() functionality in Opera 11.50 and beyond

Check out this javascript demonstration: http://fiddle.jshell.net/maple/JbEJN/show/ (for the code, refer to this link: http://jsfiddle.net/maple/JbEJN/). This is a basic tab control created with JavaScript. Clicking 'Tab 1' reveals the contents ...

Unexpected issue encountered when working with JSON in Node.js

I've searched through countless solutions on stackoverflow, but none of them seem to work for me. It's really frustrating not understanding what's going wrong. Below is the code I'm having trouble with: var data = ""; req.on('dat ...

Checkbox selection causing Bootstrap accordion to collapse

Hey everyone, I'm currently working with Bootstrap 5 accordion and facing an issue where the input checkbox is triggering the "collapse" event of the accordion. I attempted to relocate the checkbox outside the scope of the accordion button but that so ...

How to Align CAShapeLayer in the Middle of a UIView Using Swift

I'm struggling to properly center a CAShapeLayer within a UIView. Despite my efforts to find a solution, most of the suggestions are outdated and have not been resolved. As shown in the image below, the shape is contained within the red view, but for ...

Oops! The reference error was not caught: CallApi has not been declared

Recently, I encountered an issue while trying to utilize a submit button to call an API. Upon inspecting the page in Chrome, I found the following errors: Uncaught ReferenceError: CallApi is not defined Here is the code snippet that I am using: < ...

Turn off pagination for tables in Material-UI

Currently, I am utilizing the TablePagination component from Material-UI in my React project. Unfortunately, this component does not come with a built-in disabled prop. I do have a boolean variable called loading that I would like to utilize as a paramet ...

What is the best way to give this CSS button a "highlight" effect when it is clicked using either CSS3 or JavaScript?

In the HTML page, I have two buttons implemented with the following code: <!-- Button for WIFI projects: --> <a title="WIFI" href="javascript: void(0)" id="showWifi_${item.index}" class="showWifi"> <div class="news_box news_box_01 hvr-u ...

Can you please provide me with the compilerOptions properties needed to create a .js file from a .tsx file in React Native using TypeScript?

For the past day, I've been diving into typescript in react native. Setting up typescript in my react-native project has been a focus as I try to convert .tsx files into .js files within the realm of react native typescript. I attempted to tweak the ...

Node.js encountering req.body as undefined when using form-data as the content-type

After creating a small demonstration for this form-data passing API, I attempted to test it using Postman. However, I encountered an issue where no data was being retrieved. Code const http = require("http"); const express = require("expres ...

Memory problem with rendering text on a 2D canvas in ThreeJs

How can I optimize my code for rendering nearly 200 texts using 2D canvas rendering? The current method is consuming a lot of memory. Is there a way to reuse the canvas element? Here is a snippet of my current implementation: var goalCanvas = document.c ...

Deciphering Complex JSON Data Structures Using JavaScript

UPDATED OUTPUT I successfully utilized the request module, which now delivers verified standard JSON output. Check out the updated result below: const respBody = { "items" : [ { "id" : "T0lDX0J1aWxkX0FydGlmYWN0czpmODk4YjM5MDNjYjk5NzU5NjgzNTk3ZWRj ...

Addressing the issue of pm2 with netmask 1.0.6 posing a serious security risk

While working on my project, I encountered a problem in the terminal when using the pm2-runtime command for the runtime environment. When running the command npm i, I received warnings at two levels: High netmask npm package vulnerable to octa ...

What is the best way to target the shadow DOM host element specifically when it is the last child in the selection?

I want to style the shadow DOM host element as the last child. In this particular situation, they are currently all green. I would like them to be all red, with the exception of the final one. class MyCustomElement extends HTMLElement { constructor() ...

What is the best way to cycle through a JSON array of objects using JavaScript and jQuery?

Currently, my focus is on understanding JavaScript and JSON objects along with arrays. One of the tasks assigned to me involves iterating through the following array: {"6784": {"OD": [ { "od_id":"587641", ...

Setting up Intern to configure my server mock before and after testing

Currently, I am in the process of creating a test suite for a JavaScript widget with Intern. While I have successfully crafted some pure-JavaScript tests as well as some DOM tests within the page, I've hit a roadblock when it comes to writing functio ...