Skip to content

Instantly share code, notes, and snippets.

@phuochau
Last active October 25, 2017 23:48
Show Gist options
  • Save phuochau/f2cf3214ce034bb75931cadec434c633 to your computer and use it in GitHub Desktop.
Save phuochau/f2cf3214ce034bb75931cadec434c633 to your computer and use it in GitHub Desktop.
Better runAfterInteractions for React Native
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