react native state

react native state

import React,{useState} from 'react'
import {View, Text,StyleSheet,Button} from 'react-native'import Constants from 'expo-constants'
function App() {
const [name,setName]=useState("sagar")
return (
<View style={des.view}>
{
name ? <Text>name:{name} variable mein data hai</Text>:<Text>data nahi hai</Text>
}
<Button
title="save"
color="green"
onPress={()=>

setName("try")

}

/>
</View>
)

}
const des=StyleSheet.create({

view:
{
flex:1,

padding:20

},
img:
{
flex:1
}
})
export default App;

0 Comments