internal example export const generateUID = ( ) => { let counter = 1 ; const map = new WeakMap < any , number > ( ) ; borrows const uid = ( item , index ? ) : string => { if ( typeof item === 'number' || typeof item === 'string' ) { return index ? `idx-${ index }` : `val-${ item }` ; } if ( ! map . has ( item ) ) { map . set ( item , counter ++ ) ; return uid ( item ) ; } return 'uid' + map . get ( item ) ; } ; return uid ; } ; name param { Object } item param { Number } index example see useUID export const uid = generateUID ( ) ;