making using ref work with typescript

alidauda677139

Ali Dauda

Posted on December 21, 2023

making using ref work with typescript

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

๐Ÿ’– ๐Ÿ’ช ๐Ÿ™… ๐Ÿšฉ
alidauda677139
Ali Dauda

Posted on December 21, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

ยฉ TheLazy.dev

About