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
| /* eslint-disable no-inner-declarations */ | |
| import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment'; | |
| let isEnabled = false; | |
| if (canUseDOM) { | |
| /** | |
| * Web browsers emulate mouse events (and hover states) after touch events. | |
| * This code infers when the currently-in-use modality supports hover | |
| * (including for multi-modality devices) and considers "hover" to be enabled |
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
| //////////////////////////////////////////////////////////////////////////////// | |
| // Create a directory called "pages" next to | |
| // this file, put markdown files in there, and | |
| // then run: | |
| // | |
| // ``` | |
| // $ node build.mjs | |
| // ``` | |
| // | |
| // Then deploy the "build" directory somewhere. |
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 useNativeSWR from 'swr' | |
| import { useRef } from 'react' | |
| // inspired by https://github.com/vercel/swr/discussions/456 | |
| export default function useSWR(key, fetcher, options = {}) { | |
| const { cachePolicy, ...opts } = options | |
| const random = useRef(new Date()) | |
| return useNativeSWR( | |
| () => { |
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 { ConfigInterface, useSWRInfinite } from 'swr' | |
| import { useMemo, useCallback, useRef } from 'react' | |
| import last from 'lodash.last' | |
| import get from 'lodash.get' | |
| type PageKeyMaker<Page, Key extends any[]> = ( | |
| index: number, | |
| previousPageData?: Page | |
| /** | |
| * Mutable ref object. Set this to `true` before the request and `false` afterwards if the request is fetching more. |
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 { useEffect, useRef } from 'react' | |
| export default function useOnChange<T>( | |
| value: T, | |
| effect: (prev: T, next: T) => void | |
| ) { | |
| const latestValue = useRef(value) | |
| const callback = useRef(effect) | |
| callback.current = effect |
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
| // pages/_app.js | |
| import ReactNativeNextJsScrollRestore from '../react-native-next-scroll-restore' | |
| import { useEffect } from 'react' | |
| function MyApp({ Component, pageProps }) { | |
| useEffect(() => { | |
| const unsubscribe = ReactNativeNextJsScrollRestore.initialize() | |
| return () => { |
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 { | |
| Exchange, | |
| cacheExchange, | |
| createClient, | |
| dedupExchange, | |
| fetchExchange, | |
| subscriptionExchange, | |
| } from 'urql' | |
| import { delay, empty, fromPromise, map, mergeMap, pipe, tap } from 'wonka' | |
| import firebase from 'firebase' // NOTE: This is old Firebase version |
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
| diff --git a/node_modules/@expo/next-adapter/build/withExpo.js b/node_modules/@expo/next-adapter/build/withExpo.js | |
| index 2e63eb4..b1cf9a9 100644 | |
| --- a/node_modules/@expo/next-adapter/build/withExpo.js | |
| +++ b/node_modules/@expo/next-adapter/build/withExpo.js | |
| @@ -7,8 +7,8 @@ function withExpo(nextConfig = {}) { | |
| // Prevent define plugin from overwriting Next.js environment. | |
| process.env.EXPO_WEBPACK_DEFINE_ENVIRONMENT_AS_KEYS = 'true'; | |
| const expoConfig = addons_1.withUnimodules(config, { | |
| - projectRoot: nextConfig.projectRoot || process.cwd(), | |
| - }, { supportsFontLoading: false }); |
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, { ComponentProps } from 'react' | |
| import { ScrollView } from 'react-native' | |
| import { useDraggableScroll } from './use-draggable-scroll' | |
| export const DraggableScrollView = React.forwardRef< | |
| ScrollView, | |
| ComponentProps<typeof ScrollView> | |
| >(function DraggableScrollView(props, ref) { | |
| const { refs } = useDraggableScroll<ScrollView>({ | |
| outerRef: ref, |