01-React Js Intro
01-React Js Intro
React.createElement()
JSX
JSX
• JSX atau extended JavaScript adalah suatu pengembangan JavaScript dimana kode HTML bisa
diikutsertakan dalam JavaScript.
Contoh:
• Sebuah component merepresentasikan bagian dari UI yang dapat digunakan kembali dan
dapat digunakan dimana saja. Terdapat dua komponen utama React yaitu:
1. Functional Component (stateless component)
2. Class Component (stateful component)
Perbedaan Functional dan Class Component:
Functional Component Class Component
It is simple JavaScript functions that simply It is regular ES6 classes that extends component
returns html UI class form react library
It is also called “stateless” components because Also known as “stateful” components because
they simply accept data and display them in some they implement logic and state.
form that is they are mainly responsible for
rendering UI.
There is no render method used in functional It must have render() method returning html
components.
It gives solution without using state It has complex UI Logic
It accept properties(props) in function and return You pass props to class components and access
html(JSX) them with this.props
React Component (Contoh)
Functional Component Class Component
Terimakasih