I am generating a list of random strings and rendering using FlatList in react native , but i want to display how long it takes to render that list also . How can i do that in react native ?
const [list,setList] = useState([]);
useEffect(()=>{
let rList=[];
for(let i=0;i<1000;i++){
rList =[...rList,Math.random().toString(36).slice(2, 7)]
}
console.log((new Date() - start)/86400000);
setList(rList);
clearTimeout()
},[])
return (
<View style={styles.container}>
<View style={styles.header}>
<Text style={styles.boldHeader}>Header</Text>
</View>
<View style={styles.body}>
<FlatList
data = {list}
renderItem = {({item})=>(
<Text>{item}</Text>
)}
/>
</View>
</View>
);
2
Answers
Implement
onLayout
prop for theText
component to measure the span of time it takes between rendering the first text and the last text in the list.For example,
Try out Snack