Last active
October 25, 2017 23:48
-
-
Save phuochau/f2cf3214ce034bb75931cadec434c633 to your computer and use it in GitHub Desktop.
Better runAfterInteractions for React Native
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { InteractionManager } from 'react-native'; | |
export const runAfterInteractions = (f) => { | |
let called = false; | |
const timeout = setTimeout(() => { called = true; f(); }, 500); | |
InteractionManager.runAfterInteractions(() => { | |
if (called) return; | |
clearTimeout(timeout); | |
f(); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment