We have an issue when calling a function that does some redux store dispatch and computations, it will take considerably longer when called from the KeyEvent listener, than calling it directly from, for example, a Button onPress.
In the attached code, if I call the saveData function directly from the Button onPress it takes between 6 and 20 milliseconds.
If I call the function from within the KeyEvent, it will take a lot longer. Consistently between 40 and 60+ milliseconds.
In this case, using an anonymized repo, with such small times it's not really a problem, but we have some more real-life complex code where a 1-second operation takes 6 or 7 seconds when called from the KeyEvent listener, which is very much noticeable.
We have an issue when calling a function that does some redux store dispatch and computations, it will take considerably longer when called from the KeyEvent listener, than calling it directly from, for example, a Button onPress.
In the attached code, if I call the saveData function directly from the Button onPress it takes between 6 and 20 milliseconds. If I call the function from within the KeyEvent, it will take a lot longer. Consistently between 40 and 60+ milliseconds.
I've created a repo to show the issue. https://github.com/fdibQat/rn-keyevent-perfomance
In this case, using an anonymized repo, with such small times it's not really a problem, but we have some more real-life complex code where a 1-second operation takes 6 or 7 seconds when called from the KeyEvent listener, which is very much noticeable.