This file contains 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
'use client'; | |
import createCache from '@emotion/cache'; | |
import {CacheProvider, EmotionCache} from '@emotion/react'; | |
import { | |
SerializedStyles, | |
StyleSheet | |
} from '@emotion/utils/dist/declarations/types'; | |
import {useServerInsertedHTML} from 'next/navigation'; | |
import {FC, PropsWithChildren, useCallback, useMemo} from 'react'; |
This file contains 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, useState} from 'react'; | |
export const useBounceValue = <TValue,>( | |
newValue: TValue, | |
defaultValue: TValue, | |
delay: number | |
) => { | |
const [value, setValue] = useState<TValue>(defaultValue); | |
useEffect(() => { |
This file contains 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
{ | |
"AED": "United Arab Emirates Dirham", | |
"AFN": "Afghan Afghani", | |
"ALL": "Albanian Lek", | |
"AMD": "Armenian Dram", | |
"ANG": "Netherlands Antillean Guilder", | |
"AOA": "Angolan Kwanza", | |
"ARS": "Argentine Peso", | |
"AUD": "Australian Dollar", | |
"AWG": "Aruban Florin", |
This file contains 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 { | |
DependencyList, | |
Dispatch, | |
MutableRefObject, | |
SetStateAction, | |
useCallback, | |
useEffect, | |
useRef, | |
useState | |
} from 'react'; |
This file contains 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
/** | |
* "document_id" -> "document id" | |
* "documentId" -> "document id" | |
*/ | |
export const toSpaces = (str: string): string => | |
str && str | |
.replace(/[-_]/g, ' ') | |
.replace(/([A-Z])/g, ' $1'); | |
/** |
This file contains 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 {useMemo} from 'react'; | |
/** | |
* Prevents React.DOM from replacing methods inside hooks. | |
*/ | |
const ref = { | |
log: console.log, | |
error: console.error, | |
debug: console.debug | |
}; |
This file contains 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 {DependencyList, useEffect, useMemo} from 'react'; | |
export const useInterval = ( | |
callback: () => void, | |
ms: number, | |
deps: DependencyList | |
) => { | |
const all_deps = useMemo( | |
() => [callback, ms, ...deps], | |
// eslint-disable-next-line react-hooks/exhaustive-deps |
This file contains 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 {FC, useEffect} from 'react'; | |
export interface RepeaterProps { | |
disabled?: boolean; | |
emitFirst?: boolean; | |
onRepeat: () => void; | |
speed: number; |
This file contains 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 {FC, useEffect} from 'react'; | |
export interface KeyPressedProps { | |
keyCode: string; | |
onPress: () => void; | |
onRelease: () => void; | |
} |
This file contains 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 {useCallback, useEffect, useState} from 'react'; | |
export const useStateStorage = <TType extends any>( | |
key: string, | |
defaultValue: TType | |
) => { | |
const [value, setState] = useState(defaultValue); | |
useEffect(() => { | |
const store = localStorage.getItem(key); |
NewerOlder