这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Jan 13, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions boilerplate/app/app.tsx.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import "./i18n"
import React, { useState, useEffect } from "react"
import { AppRegistry, YellowBox } from "react-native"
import { StatefulNavigator } from "./navigation"
import { StorybookUIRoot } from "../storybook"
import { RootStore, RootStoreProvider, setupRootStore } from "./models/root-store"
import { BackButtonHandler, exitRoutes } from "./navigation"
import { contains } from "ramda"
Expand Down Expand Up @@ -89,5 +88,11 @@ const APP_NAME = "<%= props.name %>"
// ⚠️ Leave this as `false` when checking into git.
const SHOW_STORYBOOK = false

const RootComponent = SHOW_STORYBOOK && __DEV__ ? StorybookUIRoot : App
let RootComponent = App
if (__DEV__) {
// Only include Storybook if we're in dev mode
const { StorybookUIRoot } = require("../storybook")

if (SHOW_STORYBOOK) RootComponent = StorybookUIRoot
}
AppRegistry.registerComponent(APP_NAME, () => RootComponent)
18 changes: 14 additions & 4 deletions boilerplate/app/models/environment.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
import { Reactotron } from "../services/reactotron"
import { Api } from "../services/api"

let ReactotronDev = undefined
if (__DEV__) {
const { Reactotron } = require("../services/reactotron")
ReactotronDev = Reactotron
}

/**
* The environment is a place where services and shared dependencies between
* models live. They are made available to every model via dependency injection.
*/
export class Environment {
constructor() {
// create each service
this.reactotron = new Reactotron()
if (__DEV__) {
// dev-only services
this.reactotron = new ReactotronDev()
}
this.api = new Api()
}

async setup() {
// allow each service to setup
await this.reactotron.setup()
if (__DEV__) {
await this.reactotron.setup()
}
await this.api.setup()
}

/**
* Reactotron is only available in dev.
*/
reactotron: Reactotron
reactotron: typeof ReactotronDev

/**
* Our api.
Expand Down