Skip to content

Instantly share code, notes, and snippets.

@OkancanCosar
Last active January 25, 2024 08:00
Show Gist options
  • Save OkancanCosar/3e350700b2fe8ceaa1234f2aebe54c18 to your computer and use it in GitHub Desktop.
Save OkancanCosar/3e350700b2fe8ceaa1234f2aebe54c18 to your computer and use it in GitHub Desktop.
InteractionManager.runAfterInteractions example
import React, { useState, useRef, useEffect } from 'react';
import {
Text,
InteractionManager,
} from 'react-native';
export default function App() {
const [screenLoading, setScreenLoading] = useState(true);
useEffect(()=>{
InteractionManager.runAfterInteractions(() => {
// 2: Component is done animating
// 3: Start fetching data that is needed to render UI
setScreenLoading(false) //Set screenloading prop to false
});
},[])
return (
//render skeleton placeholder/any placeholder when screenLoading is true
//then
//render appropirate UI based on heavy computation when the data is been successfully fetched from server
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment