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

Popular posts from this blog

Send Data Child to Parent Component - React Js

Hide , Show and Toggle in ReactJs

Importance Of Web Content In SEO.