How to use the mobx-react/native.inject function in mobx-react

To help you get started, we’ve selected a few mobx-react examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jsappme / react-native-firebase-starter / src / views / login_screen.js View on Github external
Image
} from 'react-native'
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'
import { getColor } from '../components/config'
import Background from '../components/background'
import InitialView from '../components/login_screen/initial_view'
import SignInForm from '../components/login_screen/signIn_form'
import SignUpForm from '../components/login_screen/signUp_form'
import ForgotPassForm from '../components/login_screen/forgotPassword_form'
import { firebaseApp } from '../firebase'
import { observer, inject } from 'mobx-react/native'
import { Actions } from 'react-native-mobx'
import OneSignal from 'react-native-onesignal'


@inject("appStore") @observer
export default class LoginScreen extends Component {
  constructor(props) {
    super(props)
    this.state = {
      initialScreen: false,
      signIn: false,
      signUp: false,
      forgotPass: false
    }
    if (Platform.OS === 'android') {
      UIManager.setLayoutAnimationEnabledExperimental(true)
    }
    _unsubscribe = firebaseApp.auth().onAuthStateChanged((user) => {
      if (user) {
        console.log("--------- LOGGED AS " + user.displayName + " ---------")
        this.props.appStore.user = user
github Vizards / uestc-react-native-ios / scene / Exam / containers / arrangement.js View on Github external
TouchableOpacity,
  StyleSheet,
  ActionSheetIOS,
  Dimensions
} from 'react-native';
import { inject, observer } from "mobx-react/native";
import moment from 'moment';
import 'moment/locale/zh-cn';

import semester from '../../../common/helpers/semester';
const current = require('../../../common/helpers/current');
const SCREEN_HEIGHT = Dimensions.get('window').height;

moment.locale('zh-cn');

@inject('rootStore')
@observer
export default class Arrangement extends React.Component {

  constructor(props) {
    super(props);
    this.state = {
      examData: [],
      year: '',
      isNull: false,
      semester: '',
      selectedText: '',
      refreshing: false,
    }
  }

  _renderItem = (info) => {
github trazyn / SoundcloudMobX / src / screens / Profile / Liked.js View on Github external
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { inject, observer } from 'mobx-react/native';
import {
    View,
    Text,
    TouchableOpacity,
    Dimensions,
    StyleSheet,
} from 'react-native';

import FadeImage from '../../components/FadeImage';

@inject(stores => ({
    list: stores.profile.liked,
    getList: () => {
        stores.profile.getLiked(stores.session.user.id);
    },
    isPlaying: () => {
        var uuid4player = stores.player.playlist.uuid;
        var uuid = stores.profile.liked.uuid;

        return uuid4player
            && uuid
            && uuid === uuid4player;
    },
}))
@observer
export default class Liked extends Component {
    static propTypes = {
github bailabs / tailpos / src / stories / components / SummaryModalComponent.js View on Github external
import * as React from "react";
import { View, Dimensions, Modal, StyleSheet } from "react-native";
import { Text, Container, Button } from "native-base";
import { formatNumber } from "accounting-js";
import { inject, observer } from "mobx-react/native";
import { Col, Row, Grid } from "react-native-easy-grid";
let MoneyCurrency = require("money-currencies");
import { currentLanguage } from "../../translations/CurrentLanguage";

import translation from "../.././translations/translation";
import LocalizedStrings from "react-native-localization";
let strings = new LocalizedStrings(translation);
@inject("receiptStore")
@observer
export default class SummaryModalComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      comissionTotal: 0,
      commissioned: [],
    };
  }

  componentWillMount() {
    this.props.receiptStore.defaultReceipt.lines.map(val => {
      let ComHolder = JSON.parse(val.commission_details);
      ComHolder.map(val2 => {
        let AtArray = 0;
        let AtIndex = null;
github hotchpotch / react-navigation-mobx-example / src / SimpleStack.js View on Github external
title="Go to a profile screen"
    />
    <button> nav.navigate('Photos', { name: 'Jane' })}
      title="Go to a photos screen"
    /&gt;
    </button><button> nav.goBack(null)} title="Go back" /&gt;
  
));

const MyHomeScreen = () =&gt; ;
MyHomeScreen.navigationOptions = {
  title: 'Welcome',
};

const MyPhotosScreen = inject('nav')(({ nav }) =&gt; (
  
));

MyPhotosScreen.navigationOptions = {
  title: 'Photos',
};

const MyProfileScreen = inject('nav')(({ nav }) =&gt; (
  
));
MyProfileScreen.navigationOptions = ({ navigation }) =&gt; {
  const { state, setParams } = navigation;
  return {
    title: `${state.params.name}'s Profile!`,</button>
github FiberJW / pul / screens / GetPasswordScreen.js View on Github external
TextInput,
  Keyboard,
  Alert,
  ActivityIndicator
} from "react-native";
import colors from "kolors";
import { NavigationStyles } from "@expo/ex-navigation";
import Router from "Router";
import Icon from "../components/CrossPlatformIcon";
import connectDropdownAlert from "../utils/connectDropdownAlert";
import KeyboardAwareScrollView from "../components/KeyboardAwareScrollView";
import { observer, inject } from "mobx-react/native";
import { observable } from "mobx";

@connectDropdownAlert
@inject("authStore")
@observer
export default class GetPasswordScreen extends Component {
  static route = {
    navigationBar: {
      visible: true,
      tintColor: colors.black,
      borderBottomColor: "transparent",
      backgroundColor: "white"
    },
    styles: {
      ...NavigationStyles.SlideHorizontal
    }
  };

  static propTypes = {
    school: PropTypes.object.isRequired,
github Vizards / uestc-react-native-ios / scene / Course / containers / Calendar.js View on Github external
import React from 'react';
import {View, ScrollView, Text, StyleSheet, TouchableOpacity, SectionList, ActionSheetIOS, Dimensions, Switch, Alert, Linking} from 'react-native';
import { withNavigation } from "react-navigation";
import { inject, observer } from "mobx-react/native";

import RNCalendarEvents from 'react-native-calendar-events';
import BEMCheckBox from 'react-native-bem-check-box';
import DatePicker from 'react-native-datepicker';
import moment from 'moment';
import 'moment/locale/zh-cn';

moment.locale('zh-cn');
const SCREEN_HEIGHT = Dimensions.get('window').height;

@inject('rootStore')
@observer
class Calendar extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      courseData: [],
      isNull: false,
      needNotice: false,
      before: 0,
      minutes: '',
      noticeText: '开启推送通知',
      startDate: '',
      buttonDisabled: false,
    };
  }
github trazyn / JJJkkk / src / screens / User / index.js View on Github external
import Icon from 'react-native-vector-icons/Ionicons';
import {
    View,
    Text,
    ScrollView,
    FlatList,
    TouchableOpacity,
} from 'react-native';

import classes from './classes';
import humanNumber from 'utils/humanNumber';
import Loader from 'ui/Loader';
import FollowButton from './FollowButton';
import FadeImage from 'ui/FadeImage';

@inject(stores => ({
    loading: stores.user.loading,
    query: stores.user.query,
    getFavorite: stores.user.getFavorite,
    user: stores.user.data,
    favorite: stores.user.favorite,
}))
@observer
export default class User extends Component {
    componentWillMount() {
        var { params, query, getFavorite } = this.props;

        query(params.id);
        getFavorite(params.id);
    }

    renderFavorite(item, index) {
github himelbrand / mobx-react-navigation-store / ReactNativeExample / screens / ScreenFive.js View on Github external
import React, { Component } from 'react'
import { View, Text, StyleSheet } from 'react-native'
import { Button } from '../components'
import { observer, inject } from 'mobx-react/native';

@inject('NavigationStore')
@observer
class ScreenFive extends Component {
    constructor(props) {
        super(props)
    }

    render() {
        this.props.NavigationStore.setNavigation('NavOne',this.props.navigation)

        return (