Props in React Native Example
App.js:-
import React, { useState } from 'react';
import { Text, Button, View } from 'react-native';
const App = () => {
const [name, setName]=useState("Krishan")
return (
<View>
<Text style={{ fontSize: 50 }}>Props in react native</Text>
<Button title='Update Name' onPress={()=>setName("Brijesh")}/>
<User name={name} age={32}/>
</View>
);
};
const User = (Props) => {
return (
<View style={{backgroundColor:'green'}}>
<Text style={{ fontSize: 50 }}>{Props.name}</Text>
<Text style={{ fontSize: 50 }}>{Props.age}</Text>
</View>
);
};
export default App;
Comments
Post a Comment