Commit 1d665a97 authored by Prasetya Saputra's avatar Prasetya Saputra

update useeffect

parent bf93c12b
import React from 'react';
import { StatusBar } from 'expo-status-bar';
import { useState } from 'react';
import { useState, useEffect } from 'react';
import { StyleSheet, Text, View, TextInput, Button, ToastAndroid, BackHandler } from 'react-native';
import { Card } from 'react-native-elements';
import { NavigationContainer } from '@react-navigation/native';
......@@ -96,13 +96,19 @@ function ListTitle({ navigation: { navigate } }) {
const [Title, setTitle] = useState([]);
Axios.get('https://jsonplaceholder.typicode.com/albums').then(function (response) {
console.log(response.data);
setTitle(response.data)
})
.catch(function (error) {
console.log(error);
});
useEffect(() => {
//subscribe
Axios.get('https://jsonplaceholder.typicode.com/albums').then(function (response) {
console.log(response.data);
setTitle(response.data)
})
.catch(function (error) {
console.log(error);
});
return function(){
//Unsubscribe
};
}, []);
return (
<View style={{ marginTop: 25 }}>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment