Skip to content

Instantly share code, notes, and snippets.

View Stringsaeed's full-sized avatar
🏗️
building something that matters

Muhammad Saeed Stringsaeed

🏗️
building something that matters
View GitHub Profile
@Stringsaeed
Stringsaeed / AnimatedScrollHeader.tsx
Created February 19, 2022 20:17
Animated Scroll Header context using react native reanimated
// Animated Scroll Header Context
// imports react and Animated
import React, {createContext, useContext} from 'react';
import {clamp} from 'react-native-redash';
import {NativeScrollEvent, NativeSyntheticEvent, ViewStyle} from 'react-native';
import Animated, {
Extrapolate,
interpolate,
useAnimatedScrollHandler,
useAnimatedStyle,
@Stringsaeed
Stringsaeed / setupJest.js
Created February 20, 2022 13:16
React Native setup jest
import 'react-native-gesture-handler/jestSetup';
import mockAsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock';
require('react-native-reanimated/lib/reanimated2/jestUtils').setUpTests();
jest.useFakeTimers();
jest.mock('react-native-reanimated', () => {
const Reanimated = require('react-native-reanimated/mock');
@Stringsaeed
Stringsaeed / useGetFirstTime.js
Last active March 2, 2022 16:00
React Hook used for when user first time opens the app so if you want to show tutorial modal or load only onboarding stack in react-navigation & react-native
import { useCallback, useLayoutEffect, useState } from "react";
import { useAsyncStorage } from "@react-native-async-storage/async-storage";
const useGetFirstTime = () => {
const [firstTime, setFirstTime] = useState(false);
const { getItem, setItem } = useAsyncStorage("FirstTime");
const readItemFromStorage = useCallback(async () => {
const item = await getItem();
setFirstTime(!item);
}, [getItem]);
@Stringsaeed
Stringsaeed / ScreenContainer.tsx
Created June 9, 2023 00:28
React Native + Typescript
import React, { useMemo } from "react";
import {
ScrollView,
ScrollViewProps,
StyleSheet,
View,
ViewProps,
} from "react-native";
type BaseProps<T> = T extends "scroll"