Here is a simple flow chart:
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;| import { Context, Effect } from "effect"; | |
| import { jest } from '@jest/globals'; | |
| import React, { useEffect, useState } from "react"; | |
| interface Ad { | |
| id: string | |
| trackingEvent: string | |
| } | |
| export class FireTrackingEvent extends Context.Tag("FireTrackingEvent")< |
| import { useCallback, useLayoutEffect, useRef } from 'react'; | |
| /** typescript type-safe version of [the approximate implementation of react's (no longer) proposed `useEvent` hook](https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md#internal-implementation) */ | |
| export function useEvent<Args extends Array<unknown>, Return>( | |
| handler: (...args: Args) => Return, | |
| ): typeof handler { | |
| const handlerRef = useRef(handler); | |
| useLayoutEffect(() => { | |
| handlerRef.current = handler; |
Here is a simple flow chart:
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;| type Replace< | |
| T extends string, | |
| Match extends string, | |
| Replacement extends string | |
| > = T extends `${infer Prefix}${Match}${infer Postfix}` | |
| ? `${Prefix}${Replacement}${Postfix}` | |
| : never; | |
| type ReplaceAll< | |
| T extends string, |
| #!/usr/bin/env bash | |
| DIR=$(dirname "${BASH_SOURCE[0]}") | |
| DIR=$(cd "$DIR" || exit; pwd -P) | |
| if ! type protoc &> /dev/null; then | |
| echo "Dependency 'protoc' is not installed." | |
| echo | |
| echo " If you are on macOS, you can use 'brew install protobuf'." | |
| echo |
| import { useEffect } from "react"; | |
| import { Keyboard } from "react-native"; | |
| import { useState } from "./mounted"; | |
| export function useKeyboardHeight() { | |
| const [keyboardHeight, setKeyboardHeight] = useState(0); | |
| useEffect(() => { | |
| const showSubscription = Keyboard.addListener('keyboardDidShow', e => setKeyboardHeight(e.endCoordinates.height)); | |
| const hideSubscription = Keyboard.addListener('keyboardWillHide', () => setKeyboardHeight(0)); |
| // Tired of seeing the | |
| // `Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.` | |
| // error? | |
| // Then use these utility hooks to make sure things don't happen in unmounted components! | |
| import { useCallback, useEffect, useRef, useState } from "react"; | |
| import type { Dispatch, SetStateAction, DependencyList } from 'react' | |
| export function useMountedRef() { | |
| const mountedRef = useRef(true); |
| *dist* | |
| *.json | |
| yarn.lock | |
| *.proto | |
| *.md | |
| Makefile | |
| .eslintignore |
| /** | |
| * @see {@tutorial https://github.com/typicode/husky} | |
| * _Requires Node >= 10 and Git >= 2.13.0._ | |
| */ | |
| module.exports = { | |
| hooks: { | |
| /** | |
| * @see {@tutorial https://stackoverflow.com/a/15656652/3942699} | |
| * | |
| * ___only works with files staged in git___ |