MCPcopy
hub / github.com/pmndrs/react-spring / getDefaultProps

Function getDefaultProps

packages/core/src/helpers.ts:72–89  ·  view source on GitHub ↗
(
  props: Lookup,
  transform: (value: any, key: string) => any = noopTransform
)

Source from the content-addressed store, hash-verified

70 * truthy.
71 */
72export const getDefaultProps = <T extends Lookup>(
73 props: Lookup,
74 transform: (value: any, key: string) => any = noopTransform
75): T => {
76 let keys: readonly string[] = DEFAULT_PROPS
77 if (props.default && props.default !== true) {
78 props = props.default
79 keys = Object.keys(props)
80 }
81 const defaults: any = {}
82 for (const key of keys) {
83 const value = transform(props[key], key)
84 if (!is.und(value)) {
85 defaults[key] = value
86 }
87 }
88 return defaults
89}
90
91/**
92 * These props are implicitly used as defaults when defined in a

Callers 4

runAsyncFunction · 0.90
_updateMethod · 0.90
declareUpdateFunction · 0.90
useTransitionFunction · 0.90

Calls 1

transformFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…