making using ref work with typescript

Ali Dauda - Dec 21 '23 - - Dev Community

was just wondering how i can make this typed
` function getMap() {
if (!ref.current) {
// Initialize the Map on first usage.
ref.current = new Map();
}
return ref.current;
}

ref={(node)=>{
const map = getMap();
if(!map)return;
if (node) {
map.set(cat.id, node);
} else {
map.delete(cat.id);
}

      }}
Enter fullscreen mode Exit fullscreen mode

`
i am trying to make the getMap() fucntion to be typed but i have no idea how

. .
Terabox Video Player