📕
Dan Fitz's Notes
  • README
  • Ai
    • Supervised Machine Learning
      • Introduction To Machine Learning
      • Regression With Multiple Input Variables
      • Classification
  • Csharp
    • C Sharp Advanced
      • Generics
      • Delegates
      • Lambda Expressions
      • Events
    • C Sharp Fundamentals
      • Intro To C
      • Primitive Types And Expressions
      • Non Primitive Types
      • Control Flow
      • Arrays And Lists
      • Working With Dates
      • Working With Text
      • Working With Files
      • Debugging Applications
    • C Sharp Intermediate
      • Classes
      • Association Between Classes
      • Inheritance
      • Polymorphism
      • Interfaces
  • Java
    • Inheritance Data Structures Java
      • Inheritance Polymorphism Using Overriding And Access Modifiers
      • Abstract Classes And Debugging
      • File I O And Exceptions
      • Collections Maps And Regular Expressions
    • Intro To Java
      • Introduction To Java Classes And Eclipse
      • Unit Testing Arrays And Array Lists
      • Static Variables Methods And Polymorphism Using Overloading
  • Javascript
    • Algorithms Data Structures
      • Big O Notation
      • Analyzing Performance Of Arrays And Objects
      • Problem Solving Approach
      • Problem Solving Patterns
      • Recursion
      • Searching Algorithms
      • Bubble Selection And Insertion Sort
      • Merge Sort
      • Quick Sort
      • Radix Sort
      • Data Structures Introduction
      • Singly Linked Lists
      • Doubly Linked Lists
      • Stacks And Queues
      • Binary Search Trees
      • Tree Traversal
      • Binary Heaps
    • Complete Nodejs
      • Understanding Node.js
      • REST AP Is And Mongoose
      • API Authentication And Security
      • Node.js Module System
      • File System And Command Line Args
      • Debugging Node.js
      • Asynchronous Node.js
      • Web Servers
      • Accessing API From Browser
      • Application Deployment
      • Mongo DB And Promises
    • Complete React Native
      • Working With Content
      • Building Lists
      • Navigating Users Between Screens
      • State Management
      • Handling Screen Layout
      • Setting Up An App
      • More On Navigation
      • Advanced Statement Management With Context
      • Building A Custom Express API
      • In App Authentication
    • Epic React
      • React Fundamentals
      • React Hooks
      • Advanced React Hooks
      • Advanced React Patterns
      • React Performance
    • Fireship Firestore
      • Firestore Queries And Data Modeling Course
      • Model Relational Data In Firestore No SQL
    • Functional Light Javascript
      • Intro
      • Function Purity
      • Argument Adapters
      • Point Free
      • Closure
      • Composition
      • Immutability
      • Recursion
      • List Operations
      • Transduction
      • Data Structure Operations
      • Async
    • Js Weird Parts
      • Execution Contexts And Lexical Environments
      • Types And Operators
      • Objects And Functions
      • Object Oriented Java Script And Prototypal Inheritance
      • Defining Objects
    • Mastering Chrome Dev Tools
      • Introduction
      • Editing
      • Debugging
      • Networking
      • Auditing
      • Node.js Profiling
      • Performance Monitoring
      • Image Performance
      • Memory
    • React Complete Guide
      • What Is React
      • React Basics
      • Rendering Lists And Conditionals
      • Styling React Components
      • Debugging React Apps
      • Component Deep Dive
      • Building A React App
      • Reaching Out To The Web
      • Routing
    • React Testing
      • Intro To Jest Enzyme And TDD
      • Basic Testing
      • Redux Testing
      • Redux Thunk Testing
    • Serverless Bootcamp
      • Introduction
      • Auction Service Setup
      • Auction Service CRUD Operations
      • Auction Service Processing Auctions
    • Testing Javascript
      • Fundamentals Of Testing
      • Static Analysis Testing
      • Mocking Fundamentals
      • Configuring Jest
      • Test React Components With Jest And React Testing Library
    • Typescript Developers Guide
      • Getting Started With Type Script
      • What Is A Type System
      • Type Annotations In Action
      • Annotations With Functions And Objects
      • Mastering Typed Arrays
      • Tuples In Type Script
      • The All Important Interface
      • Building Functionality With Classes
    • Web Performance With Webpack
      • Intro
      • Code Splitting
      • Module Methods Magic Comments
  • Other
    • Algo Expert
      • Defining Data Structures And Complexity Analysis
      • Memory
      • Big O Notation
      • Logarithm
      • Arrays
      • Linked Lists
      • Hash Tables
      • Stacks And Queues
      • Strings
      • Graphs
      • Trees
    • Aws Solutions Architect
      • AWS Fundamentals IAM EC 2
    • Fundamentals Math
      • Numbers And Negative Numbers
      • Factors And Multiples
      • Fractions
    • Mysql Bootcamp
      • Overview And Installation
      • Creating Databases And Tables
      • Inserting Data
      • CRUD Commands
      • The World Of String Functions
      • Refining Our Selections
      • The Magic Of Aggregate Functions
    • Random Notes
      • Understanding React Hooks
  • Python
    • Data Analysis Using Python
      • Loading Querying And Filtering Data Using The Csv Module
      • Loading Querying Joining And Filtering Data Using Pandas
      • Summarizing And Visualizing Data
    • Intro To Python
      • Course Introduction Intro To Programming And The Python Language Variables Conditionals Jupyter Notebook And IDLE
      • Intro To Lists Loops And Functions
      • More With Lists Strings Tuples Sets And Py Charm
      • Dictionaries And Files
Powered by GitBook
On this page
  • Project Generation
  • More on React Navigation
  • Types of navigators
  • Configuring App.js
  • Displaying Icons
  • onEndEditing in TextInput
  • Styling Tips
  • Displaying images
  • Displaying content that goes beyond the screen
  1. Javascript
  2. Complete React Native

Setting Up An App

Project Generation

To generate a boilerplate project, you have 2 popular CLIs available:

  • expo-cli

  • react-native-cli

The expo-cli project generator comes with a lot more useful features pre-configured, so you'll generally prefer this. (Examples include icons, video, camera use, etc.)

More on React Navigation

Types of navigators

There are 3 kinds of navigators that are commonly used:

  • DrawerNavigator

  • BottomTabNavigator

  • StackNavigator

Each of these navigators are like big objects that store the different views that can be rendered.

Configuring App.js

The App.js file is a special file where the default export is the root location from which React Native renders your entire application.

When you use react-navigation (and its associated libraries), 3 main things tend to happen in your App.js file:

  1. You create the navigator using one of the navigator types, passing in an object containing your screens.

  2. In that same navigator initialization, you pass configuration for that navigator.

  3. You export the navigator wrapped around createAppContainer. (This happens because React Native expects a React component to be exported from App.js, and the navigator by itself is not a React component.)

Simple example:

import { createAppContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';
import Search from './src/screens/SearchScreen';

const navigator = createStackNavigator(
  // 1. Object containing screens
  { Search: SearchScreen },
  // 2. Configuration
  {
    initialRouteName: 'Search',
    defaultNavigationOptions: { title: 'Business Search' },
  }
);

// 3. Wrap content in React component
export default createAppContainer(navigator);

Displaying Icons

Expo tends to give you a very useful library called @expo/vector-icons. This is a collection of React icon libraries like Ant Design, Font Awesome, etc. that you can use.

import { AntDesign } from '@expo/vector-icons';

<AntDesign name='search' size={30} />;

onEndEditing in TextInput

When a user is done adding text to an input and presses enter or submit, you use the onEndEditing prop to trigger a callback. This callback gets passed an event object.

<TextInput
  value={text}
  onChangeText={setText}
  onEndEditing={() => console.log('submitted!')}
/>

Styling Tips

Displaying images

By default, even if you give a primitive Image component a source prop, it won't appear on the page until you give the Image height and width dimensions.

Displaying content that goes beyond the screen

If your content gets long enough, it will go beyond the screen. By default, you can't get to that content.

There are 3 potential fixes to this:

  • Apply flex: 1 to the parent container, so it stretches vertically as far as possible.

  • Use a ScrollView component to add scroll-ability.

  • Remove the parent container altogether and just use a React.Fragment, so you don't have to style any parent container.

PreviousHandling Screen LayoutNextMore On Navigation

Last updated 3 years ago