Fix useEventEmitter to support passing all callback arguments

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2020-05-24 14:11:25 +01:00
parent 37d04d6ceb
commit 02ddda587b

View file

@ -32,7 +32,7 @@ export const useEventEmitter = (emitter, eventName, handler) => {
if (!emitter) return;
// Create event listener that calls handler function stored in ref
const eventListener = event => savedHandler.current(event);
const eventListener = (...args) => savedHandler.current(...args);
// Add event listener
emitter.on(eventName, eventListener);