Last active
January 25, 2024 08:00
-
-
Save OkancanCosar/3e350700b2fe8ceaa1234f2aebe54c18 to your computer and use it in GitHub Desktop.
InteractionManager.runAfterInteractions example
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 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