This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install --save-dev babel-plugin-transform-decorators-legacy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"presets": [ | |
"react-native" | |
], | |
"plugins": [ | |
"transform-decorators-legacy" | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
import { observable, action } from "mobx"; | |
export default class CounterStore { | |
@observable count = 0; | |
@action increase() { | |
this.count += 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @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() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
import App from "./App"; | |
import { AppRegistry } from "react-native"; | |
AppRegistry.registerComponent("MobXExample", () => App); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.ignoredYellowBox = ['Remote debugger is in a background']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun createReactActivityDelegate(): ReactActivityDelegate { | |
return MainActivityDelegate(this, mainComponentName!!) | |
} |