GithubHelp home page GithubHelp logo

hhy5277 / reactnativesampleapp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from taskrabbit/reactnativesampleapp

0.0 1.0 0.0 458 KB

Example app in React Native: sort of like twitter/tumblr

License: MIT License

JavaScript 88.61% Python 0.84% Java 7.44% Ruby 0.09% Objective-C 3.02%

reactnativesampleapp's Introduction

React Native Sample App

At TaskRabbit, we are trying to understand the best way to build React Native apps. This app is a working app in which we implement new ideas or those that have worked for us so far. We'll write about it on our tech blog.

The app itself is vaguely like twitter/tumblr. There are users that make posts. They follow other users. You can look at follows and their posts. The features (or styling) isn't the main point. At this time, we're mostly demonstrating architectural concepts.

Sign up Create post Show post Followers

iOS

In the root directory

  • Install dependencies: npm install

In the ios directory

  • Install Pods: gem install cocoapods
  • Install Pods: pod install
  • Install xcpretty: gem install xcpretty
  • Launch: open Sample.xcworkspace

Android

  • You might need to do this to run it in Android Studio or on real device: adb reverse tcp:8081 tcp:8081
  • And for the sample server: adb reverse tcp:3000 tcp:3000
  • To run from command line try: react-native run-android

Server

There is a server that the app hits for data. The data is only stored in memory, but it should produce a more realistic environment.

In the server directory

  • Install nvm and node-4.2.3
  • Install dependencies: npm install
  • Run it: npm start

It has sample data in the models.js file. For example, there is a user bleonard (password: "sample") that you can log in as.

Tests

The integration tests are run using Appium.

There is also an example of how to run it on Travis CI: Build Status

To run tests:

  • Make sure you have the 9.0 simulators installed in XCode
  • Compile app for the test environment: npm run compile:test
  • Launch simulator and tests: npm test

Compiling

You can compile and put it on the phone with: npm run install:staging

Not that there's a staging server at this point, but it's an example of how to compile things via the command line.

Android

We'll get there, but we're still working on the iOS version.

Current Concepts

Navigation

The sole method of navigation (what's showing on the screen and where the back button goes) is via urls. We parse urls to determine the route stack. There is some stuff to make "related" url navigation look "right" (push and pop). Making everything addressable by URL is great for deep linking and forces each screen to be able to load all on it's own from simple data.

The Router handles parsing different routes depending if you are logged in or not. The urls must be able to represent the entire navigation stack, so that means they can be recursive like my friend's friend's friend's feed (sample://dashboard/follows/john/follows/sarah/follows/amy/posts).

Flux

The Components use Actions. Actions tend to use the API Services and dispatch an event. The Stores are listening to the events. The Components add and remove listeners to the Stores.

Environment

There is a model called Environment that gets bootstrapped from Objective-C. It knows things that are different per environment like what API server to talk to.

Data storage

Info is currently stored as json to the local file system.

Shared CSS

It uses the cssVar pattern from the sample Facebook apps.

API

It uses superagent to do HTTP requests and sets headers and other things like that.

Components

Some shared components that might be helpful

  • SegmentedControl: Non-iOS specific version of that control
  • SimpleList: make a list out of the props set
  • Button: Helper to make them all similiar

Mixins

We are currently sharing code through mixins. Some of them might be generally useful.

  • KeyboardListener: helps know the amount of space the keyboard is taking up
  • DispatcherListener: subscribes and ubsubscribes from the Dispatcher for a component
  • NavigationListener: react to navigation changes in a component

Extensions

We've been trying out ways to not use mixins. AddSpinnerLoader is an example of a higher-level component.

i18n

We've internationalized our app. Each component definies it's own keys. This provides a sample of how that works.

Android too

We shipped our Android app! We need to update this to work there too.

License

MIT

reactnativesampleapp's People

Contributors

alex-mcleod avatar bleonard avatar jeffreyleeon avatar jrichardlai avatar tlenclos avatar zetavg avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.