Skip to content

Instantly share code, notes, and snippets.

{
"21": [
{
"name": "shawn",
"age": 21
},
{
"name": "nayomi",
"age": 21
}
@pasindu1
pasindu1 / script.js
Last active July 5, 2023 16:26
JjeypoG
const people = [
{name: 'shawn', age: 21},
{name: 'john', age: 23},
{name: 'alex', age: 22},
{name: 'nayomi', age: 21},
];
const finalPeopleObject = people.reduce((peopleGroupedByAge, curValue) => {
const age = curValue.age;
if(!peopleGroupedByAge[age]) peopleGroupedByAge[age] = [];
const itemsArray = [[1,4], [5,2], [9,3]];
const flattenArray = itemsArray.reduce((flattenArray, curValue) => {
return flattenArray.concat(curValue)
}, [])
console.log('flattenArray', flattenArray);
const otpContent = useMemo(() =>
<View style={styles.containerStyle}>
{Array.from({ length: 6 }).map((_, i) => (
<Text
onPress={onPress}
style={[styles.textStyle, text[i] ? styles.filledStyle : {}]}>
{text[i]}
</Text>
))}
</View>
import React, { useMemo, useRef, useState } from 'react';
import { StyleSheet, TextInput, SafeAreaView, Text, View } from 'react-native';
export enum KeyBoardTypes {
default = 'default',
email = 'email-address',
numeric = 'numeric',
phone = 'phone-pad',
url = 'url',
number = 'number-pad',
//....
const AnimatedTabs = (props: MaterialTopTabBarProps) => {
const routes = props.state.routes;
const [tabBarWidth, setTabBarWidth] = useState<number>(0);
if (routes.length <= 0) return null;
const tabWidth = tabBarWidth / (routes.length ?? 1);
const translateX = props.position.interpolate({
inputRange: routes.map((_, index) => index),
import {NavigationContainer} from '@react-navigation/native';
import React from 'react';
import {SafeAreaView, StyleSheet} from 'react-native';
import TabNavigator from './src/components/index'
function App(): JSX.Element {
return (
<SafeAreaView style={styles.safeArea}>
import {createMaterialTopTabNavigator} from '@react-navigation/material-top-tabs';
import React from 'react';
import {StyleSheet, Text, View} from 'react-native';
import CustomTabBar from './customTabBar';
const TabNav = createMaterialTopTabNavigator();
const SignUp = () => (
<View style={styles.container}>
import {MaterialTopTabBarProps} from '@react-navigation/material-top-tabs';
import React, {useState} from 'react';
import {
Animated,
LayoutChangeEvent,
StyleSheet,
Text,
TouchableOpacity,
View,
} from 'react-native';
import { interpolate, useAnimatedStyle } from 'react-native-reanimated';
const redColor = 'rgba(255, 0, 0, 1)'
const greenColor = 'rgba(0, 209, 121, 1)'
const animatedStyle = useAnimatedStyle(() => {
return {
backgroundColor: interpolate(
progress.value,
[0, 1],