Skip to content

Instantly share code, notes, and snippets.

@ashish-r
ashish-r / AutoCompleteTextViewReactNative
Created April 3, 2019 07:17
Auto Complete Text View implementation in react native
import React,{Component} from 'react';
import {View, ToastAndroid, TextInput,Text, StyleSheet, Dimensions, Measure, Keyboard, FlatList, TouchableWithoutFeedback, ViewPropTypes} from 'react-native';
import PropTypes from 'prop-types';
import BorderTextInput from './BorderTextInput';
import constants from '../../configurations/constants';
import Icon from 'react-native-vector-icons/Ionicons';
import _ from 'lodash';
import { NativeModulesCall } from '../../services/helperFunctions';
//Created By: Ashish Ranjan
@ashish-r
ashish-r / nestedObjValue.js
Last active April 3, 2019 17:30
Safely access value from a nested object
//Param1: Nested Object
//Param2: Array of keys in the desired order
//Return: Final value from given object based on the given key order if exists, else undefined
function nestedObjValue(obj, keyOrder){
return keyOrder.reduce((a,b) => typeof a !== 'object' || !a ? undefined : a[b] , obj)
}
//Examples
nestedObjValue({a: {b: {c : {d: {e: 3}}}}}, ['a','b', 'c', 'd', 'e']) //3