DEV Community

Discussion on: How to pass extra params to your handlers functions with React?

Collapse
 
ntvinhit profile image
Nguyễn Trọng Vĩnh

I dont always use Map.

Just like:

getHandler(id) {
if (!this.getHandler[id]){this.getHandler[id] = () => ...}
return this.getHandler[id];
}

You can reduce 1 line of code.

Collapse
 
eatsjobs profile image
Pasquale Mangialavori

Yeah you can use a simple object. Maybe an Object.create(null) object is even better