React Native - Notes



RN provides Fetch API that allows to fetch content from arbitrary URL:

function getUsers() {
  return fetch('')
    .then(response => response.json())
    .then(responseJson => responseJson.users)
    .catch(error => console.error(error));

example can be rewritten using async/await syntax from ES2017:

async function getUsers() {
  try {
    let response = await fetch('');
    let responseJson = await response.json();
    return responseJson.users;
  } catch (error) {

linking native libraries

native libraries can be linked:

component naming conventions and file structure

├── app
│   ├── components
│   │   ├── login
│   │   │   ├── Layout.js
│   │   │   └── PhonePage.js
// app/components/login/PhonePage.js

export default class PhonePage extends Component {
  // ...
// app/components/login/index.js

import PhonePage from './PhonePage';

export default {
// app/App.js

import Login from './components/login';

export default class App extends Component {
  // ...
  case 'login_phone_page':
    return <Login.PhonePage navigator={navigator} />;
  // ...

store.dispatch() is synchronous

dispatch is synchronous by default, so, as long as you don’t have async calls in the action creator, they execute in the order they were declared.

Yes, the original store.dispatch() function is 100% synchronous, and when it returns the state has been updated. Any asynchronicity happens if middleware intercept the action and do something different.


You can use the DEV global variable in JavaScript to determine if you’re using React Native packager or not. If you are running your app in the iOS Simulator or Android emulator DEV will be set to true.

debug and release modes

NOTE: APKs and TestFlight builds are always built in release mode.

all the notes below are true for both iOS and Android:

the value of __DEV__ variable is determined by current mode - not by current environment.

all possible combinations of environment and mode are:

UPDATE (2019-08-30)

it has turned out current mode greatly affects how application behaves - error in production sometimes can be reproduced after switching to release mode only (and conversely - it might be ignored in debug mode) => switch to release mode to fully emulate production environment.


mode is called a build configuration in Xcode parlance:

Product (top menu) → SchemeEdit Scheme...
Run (left menu) → Info (tab)