Skip to content

Instantly share code, notes, and snippets.

@ThrowJojo
ThrowJojo / decorators.sh
Created September 19, 2017 03:52
Babel transform decorators
npm install --save-dev babel-plugin-transform-decorators-legacy
@ThrowJojo
ThrowJojo / .babelrc
Created September 19, 2017 03:53
Example presets for decorators
{
"presets": [
"react-native"
],
"plugins": [
"transform-decorators-legacy"
]
}
@ThrowJojo
ThrowJojo / CounterStore.js
Created September 19, 2017 03:55
MobX store for a Counter.
// @flow
import { observable, action } from "mobx";
export default class CounterStore {
@observable count = 0;
@action increase() {
this.count += 1;
}
@ThrowJojo
ThrowJojo / Counter.js
Created September 19, 2017 03:57
A Counter Component using MobX
// @flow
import React, { Component } from "react";
import { View, Text, StyleSheet } from "react-native";
import { observer, inject } from "mobx-react";
@inject("counterStore")
@observer
export default class Counter extends Component {
render() {
@ThrowJojo
ThrowJojo / App.js
Created September 19, 2017 04:02
App file for Counter
// @flow
import React, { Component } from "react";
import { Text, View, Button, StyleSheet } from "react-native";
import CounterStore from "./stores/CounterStore";
import Counter from "./components/Counter";
import { Provider, inject } from "mobx-react";
const counterStore = new CounterStore();
@ThrowJojo
ThrowJojo / index.ios.js
Created September 19, 2017 04:07
Counter entry file for iOS
// @flow
import App from "./App";
import { AppRegistry } from "react-native";
AppRegistry.registerComponent("MobXExample", () => App);
@ThrowJojo
ThrowJojo / index.ios.js
Created September 23, 2017 00:15
Remove yellow warnings from React Native
console.ignoredYellowBox = ['Remote debugger is in a background'];
package com.aproject
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.os.PersistableBundle
import android.view.WindowManager
import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
@ThrowJojo
ThrowJojo / MainActivityDelegate.kt
Created September 25, 2017 04:20
ReactActivityDelegate example
inner class MainActivityDelegate(val activity: Activity, val mainComponentName: String): ReactActivityDelegate(activity, mainComponentName) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Do what you need to do
}
override fun onNewIntent(intent: Intent?): Boolean {
// Do what you need to do
return super.onNewIntent(intent)
@ThrowJojo
ThrowJojo / MainActivity.kt
Created September 25, 2017 04:22
Overriding createReactActivityDelegate
override fun createReactActivityDelegate(): ReactActivityDelegate {
return MainActivityDelegate(this, mainComponentName!!)
}