Skip to content

Instantly share code, notes, and snippets.

View trinadhkoya's full-sized avatar
💭
I may be slow to respond.

trinadhkoya trinadhkoya

💭
I may be slow to respond.
View GitHub Profile
@trinadhkoya
trinadhkoya / Reset to Initial State When User Logout
Created February 14, 2019 07:29
Reset to Initial State When User Logout
import {combineReducers} from 'redux';
import { LOGOUT } from '../common/constants';
import { UnauthorizedErrorReducer } from '../common/commonReducers';
import FirstReducer from './FirstReducer';
import SecondReducer from './SecondReducer';
import ThirdReducer from './ThirdReducer';
/* In order to reset all reducers back to their initial states when user logout,
* rewrite rootReducer to assign 'undefined' to state when logout
*
import React from 'react';
import {FlatList, StyleSheet} from 'react-native';
import {List, ListItem } from 'react-native-elements';
class Users extends React.Component {
state = {
seed: 1,
page: 1,
users: [],
isLoading: false,
@trinadhkoya
trinadhkoya / multipleHOC.js
Created December 27, 2018 05:55
How to handle multlple HOC(Higher Order Components) to Component in React Native/React
import {compose} from "redux";
import {connect} from "react-redux";
const composedHoc = compose(
connect(mapStateToProps),
withCurrentUser,
checkSession,
checkInternetConnection
);
/**
Author: Trinadh Koya
Created:Friday, 26 December 2016
**/
import React, { Component } from "react";
import PropTypes from "prop-types";
import {
Dimensions,
ImageBackground,
@trinadhkoya
trinadhkoya / TagSelect.js
Created December 26, 2018 04:27
Multiple Button select
import React from 'react'
import PropTypes from 'prop-types'
import {
View,
ViewPropTypes,
StyleSheet
} from 'react-native'
import TagSelectItem from './TagSelectItem'
@trinadhkoya
trinadhkoya / SessionCheckHOC.js
Last active December 25, 2018 16:45
This gist is about checking the authentication on every component
import React, {Component} from 'react'
import {connect} from 'react-redux'
export default function (ComposedComponent) {
class Authentication extends Component {
componentWillMount() {
if (!this.props.authenticated) this.props.navigation.navigate('LoginForm')
}
@trinadhkoya
trinadhkoya / imageIco.js
Created December 25, 2018 14:42
Convert SVG code to JS code with Dynamic Props
import React from 'react'
import PropTypes from 'prop-types';
import Svg, {G, Path} from "react-native-svg";
class ImageIco extends React.Component {
constructor(props) {
super(props);
}
render() {
@trinadhkoya
trinadhkoya / HOC_Authentication
Last active December 22, 2018 05:52
An HOC which checks authentication in every container/screen
import React, {Component} from 'react'
import {connect} from 'react-redux'
export default function (ComposedComponent) {
class Authentication extends Component {
componentWillMount() {
if (!this.props.authenticated) this.props.navigation.navigate('LoginForm')
}
@trinadhkoya
trinadhkoya / NetworkHelper.java
Created April 25, 2017 15:08 — forked from alphamu/NetworkHelper.java
Gist showing the use case of a headless Fragment to check if internet is available
public class NetworkHelper extends Fragment {
public static final String TAG = "NetworkHelper";
public static final String CHECK_INTERNET = "network_connection";
private Activity mActivity;
AlertDialog mAlertDialog = null;
private BroadcastReceiver onNotice = new BroadcastReceiver() {
@Override
@trinadhkoya
trinadhkoya / Locator.java
Created April 21, 2017 16:38 — forked from emil2k/Locator.java
Android utility class for getting device location using various methods.
package com.emil.android.util;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
/**