Skip to content

Instantly share code, notes, and snippets.

@JackHowa
Created June 1, 2018 00:23
Show Gist options
  • Save JackHowa/013ece252ba03eddd857e137a4fd17c4 to your computer and use it in GitHub Desktop.
Save JackHowa/013ece252ba03eddd857e137a4fd17c4 to your computer and use it in GitHub Desktop.
this is a running list of helpful commands for react native
# see available devices for the simulator
xcrun simctl list devices
react-native run-ios --simulator="iPhone 10"
@JackHowa
Copy link
Author

JackHowa commented Jun 1, 2018

react native for android
https://facebook.github.io/react-native/docs/getting-started.html

runs from index.js every time -- not app.js

@JackHowa
Copy link
Author

JackHowa commented Jun 1, 2018

basic react native

import React from 'react';
import { Text } from 'react-native';

const App = () => <Text>Hey there</Text>;

export default App;

simulator screen shot - iphone x - 2018-05-31 at 19 38 45

@JackHowa
Copy link
Author

JackHowa commented Jun 1, 2018

read the error! if not found

https://stackoverflow.com/questions/32634352/react-native-android-build-failed-sdk-location-not-found?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

Scanning folders for symlinks in /Users/jackhowa/sites/latr_v2/node_modules (20ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 7.501 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

@JackHowa
Copy link
Author

JackHowa commented Jun 1, 2018

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:installDebug'.

com.android.builder.testing.api.DeviceException: No connected devices!

@JackHowa
Copy link
Author

JackHowa commented Jun 1, 2018

Installing APK 'app-debug.apk' on 'Pixel_XL_API_23(AVD) - 6.0' for app:debug
Installed on 1 device.

BUILD SUCCESSFUL

Total time: 14.287 secs

This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html
/bin/sh: adb: command not found
Starting the app (adb shell am start -n com.latr_v2/com.latr_v2.MainActivity...

@JackHowa
Copy link
Author

JackHowa commented Jun 1, 2018

simulator screen shot - iphone 6 - 2018-05-31 at 21 01 03
simulator screen shot - iphone x - 2018-05-31 at 21 01 00

@JackHowa
Copy link
Author

JackHowa commented Jun 1, 2018

import React from 'react';
import { Text, View } from 'react-native';
import CompanyLogo from './src/components/CompanyLogo';

const App = () => {
	const { textStyle, viewStyle } = styles;
	return (
		<View style={viewStyle}>
			<CompanyLogo />
			<Text style={textStyle}>Hey there</Text>
		</View>);
}

const styles = {
	textStyle: {
		color: "#000000",
		width: 50,
		height: 50,
		backgroundColor: "white"
	},
	viewStyle: {
		height: 100,
		backgroundColor: "#ef5350",
		justifyContent: "space-between",
		alignItems: "flex-start",
		flexDirection: "row",
		flex: 1,
		paddingTop: 45
	}
}

export default App;

@JackHowa
Copy link
Author

JackHowa commented Jun 1, 2018

import React from 'react';
import { View, Text } from 'react-native';

const CompanyLogo = () => {
	const { viewStyle } = styles;
	return (
		<View style={viewStyle}>
			<Text>Logo Here</Text>
		</View>);


}; 

const styles = {
	viewStyle: {
		width: 50,
		height: 50
	}
}

export default CompanyLogo;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment