State 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");
    function testName() {
        setName("Dev")
    }
    return (
        <View>

            <Text style={{ fontSize: 50 }}>{name}</Text>
            <Button title='Press Me' onPress={testName}></Button>
        </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.