making using ref work with typescript
Ali Dauda
Posted on December 21, 2023
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);
}
}}
`
i am trying to make the getMap() fucntion to be typed but i have no idea how
๐ ๐ช ๐
๐ฉ
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.