Skip to content

Instantly share code, notes, and snippets.

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { StyleSheet, View } from 'react-native';
import FitImage from 'react-native-fit-image';
import {
Container,
Footer,
FooterTab,
Content,
import { call, put, select, take, fork, all, takeLatest } from 'redux-saga/effects';
import axios from 'axios';
import querystring from 'query-string';
import Config from 'react-native-config';
import {
REQUEST_ADMIN_ATTACHED_FACILITIES,
netWorkError,
responseAdminAttachedFacilities,
showLoading,
import { RESPONSE_ADMIN_ATTACHED_FACILITIES, ERROR } from '../actions/pickFacility';
const initialState = {
attachedFacilities: [],
msg: false,
isLoading: false,
};
export default (state = initialState, action) => {
switch (action.type) {
export const RESPONSE_ADMIN_ATTACHED_FACILITIES = 'RESPONSE_ADMIN_ATTACHED_FACILITIES';
export const ERROR = 'ERROR';
export const REQUEST_ATTACHED_FACILITIES = 'REQUEST_ATTACHED_FACILITIES';
export const responseAdminAttachedFacilities = data => ({
type: RESPONSE_ADMIN_ATTACHED_FACILITIES,
attachedFacilities: data.attachedFacilities,
});
export const errorFetchFacilties = () => ({
import { call, put, select, take, fork, all, takeLatest } from 'redux-saga/effects';
import axios from 'axios';
import querystring from 'query-string';
import Config from 'react-native-config';
import {
REQUEST_ATTACHED_FACILITIES,
responseAdminAttachedFacilities,
errorFetchFacilties,
} from '../../../actions/pickFacility';
render() {
console.log(`i am in the render method with this.props.PickFacility.msg ${this.props.PickFacility.msg}`);
const displayView = this.props.PickFacility.msg ? (
<View
style={{
flex: 1,
alignSelf: 'center',
marginTop: '50%',
@Ayyagaries
Ayyagaries / gist:a25ba98e9b2b32e3d3c4f6cbef5ba4dc
Last active April 2, 2018 20:45
reducer with REQUEST_ATTACHED_ENTITIES_STARTED
import {
RESPONSE_ADMIN_ATTACHED_FACILITIES,
ERROR,
REQUEST_ATTACHED_ENTITIES_STARTED,
} from '../actions/pickFacility';
const initialState = {
attachedFacilities: [],
msg: false,
isLoading: true,
-------------- REDUCER -----------------------
import { RESPONSE_ADMIN_ATTACHED_FACILITIES, ERROR, RESET_DATA } from '../actions/pickFacility';
const initialState = {
isLoading: true,
msg: null,
attachedFacilities: [],
};
export default (state = initialState, action) => {
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { StyleSheet, View, FlatList } from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';
import { List, ListItem, SearchBar } from 'react-native-elements';
import { Container, Content, Text, Button, Label } from 'native-base';
import Spinner from 'react-native-loading-spinner-overlay';
import { requestAttachedFacilities } from '../actions/pickFacility';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { StyleSheet, View, FlatList } from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';
import { List, ListItem, SearchBar } from 'react-native-elements';
import { Container, Content, Text, Button, Label } from 'native-base';
import Spinner from 'react-native-loading-spinner-overlay';
import { requestAttachedFacilities } from '../actions/pickFacility';