React native state not updating
Location in alert returns empty
function Home({ route, navigation }) {
const [location, setLocation] = useState('');
const _appStart = () => {
_location();
}
const _location = () => {
setLocation("Konum Ekle");
alert(location);
}
React.useEffect(() => {
const unsubscribe = navigation.addListener('focus', () => {
_appStart();
});
return unsubscribe;
}, [navigation]);
return (
{location}
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor:'#ffff',
},
})
export default Home
Top comments (0)