React Native Props | How to use props in react native

In this tutorial we will see ‘How to use props in react native’.

React native component’s properties are pronounced as props. props values assign once when component created.

Most components can be update when they are created, with different parameters. These parameters are called  props.

React native props example

in this tutorial, we will create string variable and assign “some data”, pass as props in Home component to display.

App.js

import React,{Component} from ‘react’;
import {
View,
Text,
Button
} from ‘react-native’;
import Home from ‘./Components/Home’;
const App = () => {
constData = “Some Data”;
return (
<SafeAreaView>
<View>
<Homedata={Data}/>
</View>
</SafeAreaView>
)
}
export default App;
Home.js
import React from “react”;
import {
View,
Text,
Button
} from ‘react-native’;
const Home = (Props) => {
return(
<View>
<Textstyle = {{fontSize :90}}>
{Props.data}
</Text>
</View>
)
}
export default Home;
Output:

Leave a Reply

Your email address will not be published. Required fields are marked *