-


Product List for {this.props.name}



Download 8,6 Mb.
Pdf ko'rish
bet24/37
Sana18.01.2022
Hajmi8,6 Mb.
#383795
1   ...   20   21   22   23   24   25   26   27   ...   37
Bog'liq
Designing Applications with Spring Boot 2.2 and React JS Step-by-step guide to design and develop intuitive full stack web applications by Dinesh Rajput (z-lib.org)

Product List for {this.props.name}
   
{this.state.product1}
{this.state.product2}
{this.state.product3}
   
   
   );
   }
}
export default ProdosApp;
As you can see in the preceding code, we initialized a state with some values in the constructor of the React component. This React component is
stateful because it is using the state to carry the data to the child components. In the following code, we will see how to use this stateful React
component:
import React from ‘react’;
import ReactDOM from ‘react-dom’;
import ProdosApp from ‘./ProdosApp;
ReactDOM.render(, document.getElementById(content));
The following screenshot displays the output of the code:
Figure 8.11: A stateful React component
As you can see in the preceding screenshot, we rendered data using the state in the React components. Currently, we have used hardcoded data
in the constructor of this stateful React component. In the next chapter, we will fetch this data using the REST API.
We saw how to use the state with React components, now we will see how to use the state and props together with React components. In the
following example, we will see how to combine the props and state in your front-end React-based application:


import React from ‘react’;
class ProdosApp extends React.Component {
   constructor(props) {
   super(props);
   this.state = {
   product1: “Samsung A6 Plus”,
   product2: “iPhone X Plus”,
   product3: “Vivo V15 Pro”
   }
   }
   render() {
   return (
   
   

Download 8,6 Mb.

Do'stlaringiz bilan baham:
1   ...   20   21   22   23   24   25   26   27   ...   37




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish