Download react-spring/packages/core/src/hooks/useSpring.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.12 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-spring/packages/core/src/hooks/useSpring.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-spring/packages/core/src/hooks/useSpring.ts
-
curl -L -o useSpring.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-spring/packages/core/src/hooks/useSpring.ts
2.12 kB
| import { Lookup, Remap } from '@react-spring/types' | |
| import { is } from '@react-spring/shared' | |
| import { ControllerUpdate, PickAnimated, SpringValues } from '../types' | |
| import { Valid } from '../types/common' | |
| import { SpringRef } from '../SpringRef' | |
| import { useSprings } from './useSprings' | |
| /** | |
| * The props that `useSpring` recognizes. | |
| */ | |
| export type UseSpringProps<Props extends object = any> = unknown & | |
| PickAnimated<Props> extends infer State | |
| ? State extends Lookup | |
| ? Remap< | |
| ControllerUpdate<State> & { | |
| /** | |
| * Used to access the imperative API. | |
| * | |
| * When defined, the render animation won't auto-start. | |
| */ | |
| ref?: SpringRef<State> | |
| } | |
| > | |
| : never | |
| : never | |
| /** | |
| * The `props` function is only called on the first render, unless | |
| * `deps` change (when defined). State is inferred from forward props. | |
| */ | |
| export function useSpring<Props extends object>( | |
| props: | |
| | Function | |
| | (() => (Props & Valid<Props, UseSpringProps<Props>>) | UseSpringProps), | |
| deps?: readonly any[] | undefined | |
| ): PickAnimated<Props> extends infer State | |
| ? State extends Lookup | |
| ? [SpringValues<State>, SpringRef<State>] | |
| : never | |
| : never | |
| /** | |
| * Updated on every render, with state inferred from forward props. | |
| */ | |
| export function useSpring<Props extends object>( | |
| props: (Props & Valid<Props, UseSpringProps<Props>>) | UseSpringProps | |
| ): SpringValues<PickAnimated<Props>> | |
| /** | |
| * Updated only when `deps` change, with state inferred from forward props. | |
| */ | |
| export function useSpring<Props extends object>( | |
| props: (Props & Valid<Props, UseSpringProps<Props>>) | UseSpringProps, | |
| deps: readonly any[] | undefined | |
| ): PickAnimated<Props> extends infer State | |
| ? State extends Lookup | |
| ? [SpringValues<State>, SpringRef<State>] | |
| : never | |
| : never | |
| /** @internal */ | |
| export function useSpring(props: any, deps?: readonly any[]) { | |
| const isFn = is.fun(props) | |
| const [[values], ref] = useSprings( | |
| 1, | |
| isFn ? props : [props], | |
| isFn ? deps || [] : deps | |
| ) | |
| return isFn || arguments.length == 2 ? [values, ref] : values | |
| } | |