2022-07-07
1719
#react
Iniubong Obonguko
123397
Jul 7, 2022 ⋅ 6 min read

Using custom events in React

Iniubong Obonguko Frontend developer, Vue ninja, code enthusiast. Learning every day.

Recent posts:

how to measure round-trip time using cURL

How to measure round-trip time (RTT) using cURL

Learn how to measure round-trip time (RTT) using cURL, a helpful tool used to transfer data from or to a server.

David Omotayo
Feb 26, 2025 ⋅ 10 min read

React.memo explained: When to use it (and when not to)

React.memo prevents unnecessary re-renders and improves performance in React applications. Discover when to use it, when to avoid it, and how it compares to useMemo and useCallback.

Emmanuel John
Feb 26, 2025 ⋅ 9 min read
React useCallback: When And How To Use It For Better Performance

React useCallback: When and how to use it for better performance

Learn how React’s useCallback hook boosts performance by memoizing functions and preventing unnecessary re-renders with practical examples and best practices.

Emmanuel John
Feb 26, 2025 ⋅ 6 min read
what is the virtual DOM in react

What is the virtual DOM in React?

Learn the characteristics of the virtual document object model (DOM), explore its benefits in React, and review a practical example.

Ibadehin Mojeed
Feb 26, 2025 ⋅ 9 min read
View all posts

2 Replies to "Using custom events in React"

  1. Custom events are also known as “synthetic” events.

    You need to check this statement. Synthetic events are react wrappers over native HTML events. Custom events are what you described in your article.

  2. For unsubscribe to work you need to pass the initial function. So unsubscribe(“hideList”); need the pointer to the function.

    So:
    let f = setIsOpen(false);
    subscribe(“hideList”, f);

    and later:
    return () => {
    unsubscribe(“hideList”,f);
    }

Leave a Reply