UNPKG

refun

Version:

A collection of React Hook-enabled functions that compose harmoniously with each other. Similar to `recompose`, but:

1 lines 839 B
{"version":3,"sources":["map-ref.ts"],"names":["useRef","mapRef","name","initialValue","props","ref"],"mappings":";AAAA,SAASA,MAAT,QAAuB,OAAvB;AAIA,OAAO,IAAMC,MAAM,GAAG,SAATA,MAAS,CAAuBC,IAAvB,EAAgCC,YAAhC;AAAA,SACpB,UAAgBC,KAAhB,EAA4E;AAC1E,QAAMC,GAAG,GAAGL,MAAM,CAACG,YAAD,CAAlB;AAEA,6BACKC,KADL,sBAEGF,IAFH,EAEUG,GAFV;AAKD,GATmB;AAAA,CAAf","sourcesContent":["import { useRef } from 'react'\nimport type { MutableRefObject } from 'react'\nimport type { TExtend } from 'tsfn'\n\nexport const mapRef = <N extends string, T> (name: N, initialValue: T) =>\n <P extends {}> (props: P): TExtend<P, { [K in N]: MutableRefObject<T> }> => {\n const ref = useRef(initialValue)\n\n return {\n ...props,\n [name]: ref,\n // FIXME: https://github.com/Microsoft/TypeScript/issues/13948\n } as any\n }\n"],"file":"map-ref.js"}