Disclaimer: this articles assumes a (very) basic understanding of React Native and Native Modules. If you have never played around with them, I’d recommend getting a look at the official documentation first.
Following my last article regarding event handling in both React and React Native, I have had questions regarding how to emit custom events in React Native. Programming in React Native means you are no longer in the DOM, and tools like
document.createEvent('myCustomEvent') are not available.
So, how do you manage to achieve a similar result?
Let’s figure that one out :-)
There are an awful lot of posts explaining how to use React’s event handling system, but not many that explain how it works. I have been working on React Native lately, and my struggles with event handling acted as a reminder of how important it was to understand precisely what’s going on. I thus decided to gather as much info as possible regarding event handling in React: the following is a report of what I found looking around the source code.
Conceptually speaking, event handling in React is nothing revolutionary. Its only goal is intercepting various events (clicks…
Hi! I am a software engineer at Playstation, Japan. I mostly talk about backend stuff, golang and vim. I also like cooking. My views are my own.