DEV Community

Discussion on: React: Using portals to make a modal popup

Collapse
 
rain84 profile image
rain84

@link2twenty , thank you for interesting article

I have a question.
Why you are using

[27].indexOf(e.which)
Enter fullscreen mode Exit fullscreen mode

instead of

e.which === 27
Enter fullscreen mode Exit fullscreen mode

?

Collapse
 
link2twenty profile image
Andrew Bone

It's for future proofing, whenever I want a specific key I do it that way so I can add extra keys to the array down the line.

For instance if I wanted to add the enter key I would do this.

[27, 13].indexOf(e.which)