Creating An Outside Focus And Click Handler React Component

In this article, we’ll look at how to create an outside focus and click handler with React. You’ll learn how to recreate an open-source React component (react-foco) from scratch in doing so. To get the most out of this article, you’ll need a basic understanding of JavaScript classes, DOM event delegation and React. By the end of the article, you’ll know how you can use JavaScript class instance properties and event delegation to create a React component that helps you detect a click or focus outside of any React component. https://smashingmagazine.com/2021/03/outside-focus-click-handler-react-component/

Létrehozva 4y | 2021. márc. 3. 11:20:09


Jelentkezéshez jelentkezzen be

EGYÉB POSTS Ebben a csoportban

CSS Cascade Layers Vs. BEM Vs. Utility Classes: Specificity Control

CSS can be unpredictable — and specificity is often the culprit. Victor Ayomipo breaks down how and why your styles might not behave as expected, and why understanding specificity is better than relyi

2025. jún. 19. 15:20:07 | Smashing magazine
Meet Accessible UX Research, A Brand-New Smashing Book

Meet “Accessible UX Research,” our upcoming book to make your UX research inclusive. Learn how to recruit, plan, and design with disabled participants in mind. Print shipping in August 2025. e

2025. jún. 18. 18:30:03 | Smashing magazine
What I Wish Someone Told Me When I Was Getting Into ARIA

Accessible Rich Internet Applications (ARIA) is an inevitability when working on web accessibility. That said, it’s everyone’s first time learning

2025. jún. 16. 20:10:05 | Smashing magazine
Creating The “Moving Highlight” Navigation Bar With JavaScript And CSS

In this tutorial, Blake Lundquist walks us through two methods of creating the “moving-highlight” navigation pattern using only plain JavaScript and CSS. The first technique uses the `getBoundingClien

2025. jún. 12. 0:10:06 | Smashing magazine
Decoding The SVG <code>path</code> Element: Line Commands

SVG is easy — until you meet path. However, it’s not as confusing as it initially looks. In this first installment of a pair of articles, Myriam Frisano aims to teach you the basics of <path> and

2025. jún. 9. 14:10:16 | Smashing magazine
Collaboration: The Most Underrated UX Skill No One Talks About

We often spotlight wireframes, research, or tools like Figma, but none of that moves the needle if we can’t collaborate well. Great UX doesn’t happen in isolation. It takes conversations with engineer

2025. jún. 5. 12:50:03 | Smashing magazine
Smashing Animations Part 4: Optimising SVGs

What’s the best way to make your SVGs faster, simpler, and more manageable? In this article, pioneering author and web designer Andy Clarke explains the process he relies on to prepare, optimise, an

2025. jún. 4. 13:40:07 | Smashing magazine