In computing, memoization or memoisation
is an optimization technique used primarily
to speed up computer programs by storing
the results of expensive function calls and
returning the cached result when the same
inputs occur again.
— wikipedia
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, {useRef, useMemo, useState, useCallback} from 'react'; | |
| import {Vibration, View, StyleSheet} from 'react-native'; | |
| import {Button, Text, Row} from '../../theme'; | |
| import {Send as SendIcon} from '../../Icons'; | |
| import {useMessage, useConversationEventType} from '../../../redux/msg/hooks'; | |
| import Animated, { | |
| useAnimatedStyle, | |
| useSharedValue, | |
| } from 'react-native-reanimated'; | |
| import {SwipeRow} from 'react-native-swipe-list-view'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Module } from '@nestjs/common' | |
| import { AuthService } from './auth.service' | |
| @Module({ | |
| providers: [AuthService], | |
| exports: [AuthService], | |
| }) | |
| export class AuthModule {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function useCachedAbortiveQuery<T>( | |
| query: DocumentNode, | |
| variables: Record<string, unknown>, | |
| deps: Array<any> | |
| ) { | |
| const apolloClient = useApolloClient(); | |
| const [data, setData] = useState<T>(); | |
| const [error, setError] = useState<Error | null>(null); | |
| const [loading, setLoading] = useState<boolean>(true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- how to model threaded comments (e.g. reddit comments) in SQL with a simple 'ancestors' column | |
| -- The comment tree: | |
| -- [1] | |
| -- / \ | |
| -- [2] [4] | |
| -- / \ \ | |
| -- [3] [7] [6] | |
| -- / | |
| -- [5] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { | |
| useCallback, | |
| useEffect, | |
| useState, | |
| FunctionComponent, | |
| ComponentClass, | |
| useMemo, | |
| useRef, | |
| Key | |
| } from 'react'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| render (): React$Element<Object> { | |
| let {user, kid, goal, balance} = this.props | |
| let currentLevel = this.getCurrentLevel() | |
| if (!goal) return this.renderEmptyState() | |
| let pipes = this.getPipes(goal, kid, user, currentLevel, this.getLevelToClimbTo()) | |
| return <View style={{flex: 1}}> | |
| <ColorFix color={colors.stratos} /> | |
| <ColorFix isBottom color={colors.fiftyShades} /> | |
| <Animated.ScrollView ref={this.setScrollRef} onScroll={this.onScroll} scrollEventThrottle={16} contentContainerStyle={styles.scrollContainer} style={styles.container}> | |
| <LinearGradient style={styles.backgroundImageView} colors={[colors.stratos, colors.stratos, colors.kingfisherDaisy]}> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState, useRef, useContext, useCallback } from 'react'; | |
| import { Dimensions, View, Animated } from 'react-native'; | |
| import { TabView } from 'react-native-tab-view'; | |
| import { TabScreen } from './Tab'; | |
| import { CustomTabBar } from './TabBar'; | |
| import { ThemeContext } from 'react-native-elements'; | |
| import { useHeaderHeight } from '@react-navigation/stack'; | |
| const AnimatedHeader = ({ style, content }) => { | |
| return <Animated.View style={style}>{content}</Animated.View>; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** UI element heights which used in message height calculation */ | |
| textPaddingVertical: number = 7; | |
| textPaddingHorizontal: number = 10; | |
| timeHeight: number = 12; | |
| timeTopMargin: number = 5; | |
| messageContainerVerticalMargin: number = 7; | |
| dateSeperatorVerticalMargin: number = 20; | |
| dateSeperatorHeight: number = 15; | |
| imageHeight: number = 170; | |
| imageBottomMargin: number = 10; |