Skip to content

Instantly share code, notes, and snippets.

View dilipsuthar97's full-sized avatar
:octocat:
Enjoying tech world

Dilip Suthar dilipsuthar97

:octocat:
Enjoying tech world
View GitHub Profile
@dilipsuthar97
dilipsuthar97 / useFilteredData.ts
Last active June 14, 2025 13:49
A custom hook function to search data in list of objects, it supports 2 nested objects
import { useState, useEffect, useMemo } from 'react';
// Helper function to get nested value from object by dot notation
const getValueByPath = (obj: any, path: string): any => {
return path.split('.').reduce((acc, key) => acc?.[key], obj);
};
/**
* Returns a filtered dataset and a function to update the main data source.
*

React Native ENV Config

Config setupusing scripts but not via the native scheme setup

@dilipsuthar97
dilipsuthar97 / Accordion.tsx
Created April 3, 2025 06:29
An accordion component using react-native-reanimated
import React, { FC, memo, ReactNode, useEffect } from 'react';
import { StyleProp, StyleSheet, Text, TextStyle, TouchableOpacity, View, ViewStyle } from 'react-native';
import Animated, {
Extrapolation,
interpolate,
measure,
runOnUI,
useAnimatedRef,
useAnimatedStyle,
useDerivedValue,
@dilipsuthar97
dilipsuthar97 / ImageView.tsx
Created February 27, 2025 10:25
Custom image view component with image loading loader and placeholder
import React, { memo, useCallback } from 'react';
import {
ActivityIndicator,
ImageResizeMode,
ImageSourcePropType,
ImageStyle,
StyleProp,
StyleSheet,
View,
} from 'react-native';
@dilipsuthar97
dilipsuthar97 / husky-readme.md
Last active July 3, 2025 09:49
Husky in React Native

Husky in React native

prettier + eslint + lint-staged + eslint-plugin-diff

Husky lets us run commands or script before committing or pushing our code to git. It works as a pre runner before commiting anything.

Install dependencies

yarn add -D husky prettier eslint lint-staged

@dilipsuthar97
dilipsuthar97 / ArrayUtil.java
Created December 14, 2023 08:57 — forked from mfmendiola/ArrayUtil.java
ReadableArray and ReadableMap serialization helpers for the React Native—Android bridge.
/*
ArrayUtil exposes a set of helper methods for working with
ReadableArray (by React Native), Object[], and JSONArray.
*/
package com.iodine.start;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReadableArray;
@dilipsuthar97
dilipsuthar97 / README.md
Created July 31, 2023 04:35 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@dilipsuthar97
dilipsuthar97 / hooks.js
Created October 1, 2022 07:07
List of all custom hooks
const useDebounce = (value, delay) => {
const [debouncedValue, setDebouncedValue] = useState(value);
useEffect(() => {
const handler = setTimeout(() => {
setDebouncedValue(value);
}, delay);
return () => {
clearTimeout(handler);
// --------------- LIBRARIES ---------------
import React, { memo } from 'react';
import { View, Animated, StyleSheet, Easing, PanResponder } from 'react-native';
// --------------- ASSETS ---------------
export const TRACK_HEIGHT = 32;
export const HOR_PAD = 10;
const Colors = {
@dilipsuthar97
dilipsuthar97 / token-generator.js
Created March 30, 2022 17:32 — forked from ziluvatar/token-generator.js
Example of refreshing tokens with jwt
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jsonwebtoken');