import React, { useEffect, useState } from "react";
import { View, Button} from "react-native";
const [condition,setCondition]= useState(false);
useEffect(() => {
console.log(condition);
}, [condition]);
const btnClick = () => {
setCondition((condition)=>!condition);
}
return (<View style={{ alignContent: 'center', flex: 1, justifyContent: "center" }}>
<Button title="click" color="red" onPress={btnClick}></Button>
</View>)
}
export default Test
When click "
click" btn then call
btnclick function and change
condtion value
false to
true .when will be change value of condtion then useEffect() will be callback
Comments
Post a Comment
If you any doubt of any topic then you can comment me.