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 { type ChangeEvent, useState } from "react"; | |
type SelectInputOption<TOptionValue> = { | |
label: string; | |
value: TOptionValue; | |
}; | |
interface SelectInputProps<TOptionValue> { | |
options: Array<SelectInputOption<TOptionValue>>; | |
selectedValue: TOptionValue; |
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
module.exports = (results) => { | |
const byRuleId = results.reduce((map, current) => { | |
for (const { column, line, ruleId } of current.messages) { | |
if (!map[ruleId]) { | |
map[ruleId] = []; | |
} | |
const occurrence = `${current.filePath}:${line}:${column}`; | |
map[ruleId].push(occurrence); | |
} |
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
const singleOrDefault = <TElement, TDefaultValue>( | |
array: ReadonlyArray<TElement>, | |
predicate: (element: TElement) => boolean, | |
defaultValue: TDefaultValue | |
): TElement | TDefaultValue => { | |
if (array.length === 0) { | |
throw new Error("The source sequence is empty."); | |
} | |
const element = array.find(predicate); |
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
/** | |
* https://markheath.net/post/lunchtime-linq-challenge | |
*/ | |
interface GetSecondsFromMinutesAndSecondsParameters { | |
minutes: number; | |
seconds: number; | |
} | |
const getSecondsFromMinutesAndSeconds = ({ |
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 type { ReactNode } from "react"; | |
interface AsynchronousComponentProps<TData> { | |
children: (data: NonNullable<TData>) => ReactNode; | |
data: TData; | |
isLoading: boolean; | |
loadingFallback: ReactNode; | |
hasError: boolean; | |
errorFallback: ReactNode; | |
} |
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, useState } from "react"; | |
export const useDebouncedValue = <TValue>(value: TValue, delay: number) => { | |
const [debouncedValue, setDebouncedValue] = useState(value); | |
useEffect(() => { | |
const timeout = setTimeout(() => { | |
setDebouncedValue(value); | |
}, delay); |
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 { useRef } from "react"; | |
import { useIntersectionObserver } from "../../hooks/useIntersectionObserver"; | |
import type { InfiniteScrollProps } from "./types"; | |
export const InfiniteScroll = ({ | |
loadMoreFunction, | |
isLoadingMore, | |
loadingMoreMessage, | |
hasLoadedEverything, | |
loadedEverythingMessage, |
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 } from "react"; | |
import type { UseIntersectionObserverParameters } from "./types"; | |
export const useIntersectionObserver = ({ | |
observableRef, | |
callback, | |
options, | |
}: UseIntersectionObserverParameters) => { | |
useEffect(() => { | |
const intersectionObserver = new IntersectionObserver( |
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 { type Context, useContext } from "react"; | |
import { invariant } from "../invariant"; | |
export const createSafeContextHook = <TContextValue>( | |
context: Context<TContextValue>, | |
displayName: string | |
) => { | |
return () => { | |
const contextValue = useContext(context); |
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 { forwardRef, useImperativeHandle, useRef } from "react"; | |
export interface VideoProps { | |
source: string; | |
} | |
export interface VideoRef { | |
play: () => void; | |
pause: () => void; | |
} |
NewerOlder