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:

Onlook: A React visual editor

Onlook bridges design and development, integrating design tools into IDEs for seamless collaboration and faster workflows.

Jude Miracle
Jan 27, 2025 ⋅ 8 min read
A Comprehensive Guide To JavaScript Generators

A comprehensive guide to JavaScript generators

JavaScript generators offer a powerful and often overlooked way to handle asynchronous operations, manage state, and process data streams.

Fimber Elemuwa
Jan 24, 2025 ⋅ 8 min read
​​Solving Micro-Frontend Challenges With Module Federation

​​Solving micro-frontend challenges with Module Federation

webpack’s Module Federation allows you to easily share code and dependencies between applications, helpful in micro-frontend architecture.

Peter Aideloje
Jan 23, 2025 ⋅ 7 min read
typescript object destructuring

TypeScript object destructuring and you

Whether you’re part of the typed club or not, one function within TypeScript that can make life a lot easier is object destructuring.

Lewis Cianci
Jan 22, 2025 ⋅ 5 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