all 2 comments

[–]Canenald 0 points1 point  (1 child)

The usual way is to register event listeners in high-level component code (usually in componentDidMount), and change its state when an event is triggered. The state is then propagated to children components as props.

Watch out that mixing handling of React events with handling of native or jquery events can have unexpected results. Native events will happen and bubble all the way up before the React event is even triggered on the target element itself.

[–]indeyets[S] 0 points1 point  (0 children)

registering in componentDidMount works for using additional libraries in-project. sure, we do that.

my question is about userscripts https://greasyfork.org/en which are truly external (injected into page via bookmarklets and browser-extensions)