learn_react_native

sublime snippets for react

https://github.com/facebookarchive/sublime-react

Ketika running di device dan muncul error cek:

https://stackoverflow.com/a/45409223

Saat membuat project baru misal "react-native init reactNavigate" lalu terjadi error (gagal install) maka gunakan perintah

npm cache clear --force

Bila bertemu error berkaitan dengan "babel-preset-react-native", lakukan :

npm uninstall --save babel-preset-react-native
npm install --save babel-preset-react-native@2.1.0

Referensi

State

Semacam session yang pendefinisiannya di dalam class

SET

-> STATIC

this.state ={
      nama:'irul'
}

-> DYNAMIC

this.setState({nama:text})

GET

{this.state.nama}

Props

Semacam session yang pendefinisiannya di luar class

SET

<Object_gue nama="joni"/>

GET

{this.props.nama}

Start Remote Js Debugging avd (android virtual device)

Press ⌘+D on iOS simulator, ⌘+M on Android emulator

ref : https://codeburst.io/react-native-debugging-tools-3a24e4e40e4

Genymotion

saat ingin menggunakan genymotion sebagai emulator :

  • buka genymotion
  • pilih setting -> adb -> use custom android sdk tools -> browse Android SDK nya, contoh : D:/Android/sdk
  • pilih start untuk menjalankan emulator
  • react-native run-android

Double R / Refresh emulator tidak berfungsi

  • Buka Android Virtual Device/AVD Manager
  • pilih salah satu emulator
  • edit
  • check hardware keyboard present

Import javascript

Perbandingan 1 (import method)

ES5

var add = require('lib').add; //method add class lib
console.log(add(1,2));

ES6

import {add} from 'lib';
console.log(add(1,2));

Perbandingan 2 (import whole class)

ES5

var libku = require('lib'); 

ES6

import libku from 'lib';

LEARN

1. saat Instansiasi object, awalan nama object harus huruf besar contoh

import Gs from './components/global_state';

harus "Gs" tidak bole "gs"

2. untuk set vertical/horizontal sebuah komponen gunakan flexbox
https://facebook.github.io/react-native/docs/flexbox.html

Rubah Bundle ID dari aplikasi
https://stackoverflow.com/a/44481467 https://www.npmjs.com/package/react-native-rename

Lokasi dari npm global

  • C:\Users\Iruel\AppData\Roaming\npm\node_modules
  • npm list -g --depth=0