Task 3
Task 3
const App=()=>{
const [count, setCount]= useState(0)
useEffect(()=>{
console.log('hello')
})
return(
<View>
<Text>Use Effect hooks {count}</Text>
<Button title='click' onPress={()=>setCount(count+1)}/>
</View>
);
}
export default App;
Task 2: useEffect hook ON DIFFERENT states and props like components mount and update
console.log(count)
},[count])
return (
<View>
<Text>{data}useEffect Hook {count}</Text>
<Button title='counter' onPress={()=>setCount(count+1)}/>
<Button title='data' onPress={()=>setData(data+1)}/>
</View>
);
};
const User=(props)=>{
console.log(props.info)
useEffect(()=>{
},[props.info.data])
return(
<View>
<Text style={{fontSize:20, color:'red'}}> DATA:{props.info.data}</Text>
</View>
);
}
const App=()=>{
const [show, setShow]= useState(true)
return(
<View>
<Text style={{fontSize:20, color:'green'}}>Show hide compoents</Text>
<Button title='hide compnents' onPress={()=>setShow(!show)}/>
{
show ? <User/> :null
}
</View>
);
}
const User=()=>{
return(
<View>
<Text style={{fontSize:20, color:'red'}}>User Components</Text>
</View>
);
}
export default App;
return (
<View style={{flex:1}}>
</View>
);
}
export default App;
return (
<View style={styles.main}>
<TouchableHighlight>
<Text style={styles.box}>Button</Text>
</TouchableHighlight>
<TouchableHighlight>
<Text style={[styles.box, styles.box1]}>Success1</Text>
</TouchableHighlight>
<TouchableHighlight>
<Text style={[styles.box, styles.box2]}>Success2</Text>
</TouchableHighlight>
</View>
);
};
return(
<View style={styles.main}>
<TouchableOpacity onPress={()=>setSelectRadio(1)}>
<View style={styles.wrap}>
<View style={styles.radioButton}>
{selectRadio==1 ?<View style={styles.bg}></View> : null }
</View>
<Text style={styles.radioText}>Radio 1</Text></View>
</TouchableOpacity>
<TouchableOpacity onPress={()=>setSelectRadio(2)}>
<View style={styles.wrap}>
<View style={styles.radioButton}>
{selectRadio==2 ? <View style={styles.bg}></View> : null }
</View>
<Text style={styles.radioText}>Radio 2</Text></View>
</TouchableOpacity>
</View>
);
}
const styles= StyleSheet.create({
main:{
flex:1,
alignItems:'center',
justifyContent:'center'
},
wrap:{
flexDirection:'row',
alignItems:'center',
},
bg:{
backgroundColor:'black',
height:28,
width:28,
borderRadius:20,
margin:3
},
radioText:{
fontSize:20
},
radioButton:{
height:40,
width:40,
borderColor:'black',
borderRadius:20,
borderWidth:3,
margin:10
}
})