React Js
#9 - Class Base Component in React
Welcome to React Class Base Component Lecture.
Class Base Component in React: Class Base component are simple Javascript component that extends React's Component class.
Class Base Component has the state and all life cycle methods of React.
Discussed topcis:
- Create Class Base Component
- Basic Life Cycle of React Class Base Component
- render()
- componentDidMount()
- State
- State Update - this.setState()
- String Update
- Object Update
Simple Class Based Component Example -
import React from "react";
class App extends React.Component {
render() {
return <>...</>
}
}
export default App;
Basic Life-cycle of Class Based Component -
import React from "react";
class App extends React.Component {
// Enter Second in componentDidMount()
componentDidMount(){
// Component change logics
}
// Enter First in render()
render() {
return <>...</>
}
}
export default App;
Assign Data in State in Class Based Component -
import React from "react";
class App extends React.Component {
// Add any types of Data in state
state = {
name: "Akash", // String
level: "Intemediate", // String
age: 26, // Number
address: { // Object
house: "87/ka",
city: "Dhaka"
},
prorgammings: ["Java", "JavaScript", "PHP"] // Array
}
componentDidMount(){
// Component change logics
}
render() {
return <>...</>
}
}
export default App;
Access Data From Class Based Component in componentDidMount()-
import React from "react";
class App extends React.Component {
// Add any types of Data in state
state = {
name: "Akash", // String
level: "Intemediate", // String
age: 26, // Number
address: { // Object
house: "87/ka",
city: "Dhaka"
},
prorgammings: ["Java", "JavaScript", "PHP"] // Array
}
// Access Data from componentDidMount()
componentDidMount(){
console.log("enter componentDidMount() :>> ");
console.log("name", this.state.name); //Access Name
console.log("age", this.state.age); //Access Age
console.log("Address - City", this.state.address.city); //Access Object Data
console.log("Address - House", this.state.address.house); //Access House No
console.log("programming 1", this.state.prorgammings); // Access Array
}
render() {
return <>...</>
}
}
export default App;
Download Day 9 - Source Code of Class Base Component - https://github.com/ManiruzzamanAkash/ReactBasic2Pro/tree/Day9
Tutorial Demo Source Code -
Video -
#4 - let vs const vs var - Clear the ES6 concepts and makes simpler path to learn React
Higher Order Component in React - In depth discussion about React HOC
All Tutorials in this playlist
Popular Tutorials
Categories
-
Artificial Intelligence (AI)
11
-
Bash Scripting
1
-
Bootstrap CSS
0
-
C Programming
14
-
C#
0
-
ChatGPT
1
-
Code Editor
2
-
Computer Engineering
3
-
CSS
28
-
Data Structure and Algorithm
18
-
Design Pattern in PHP
2
-
Design Patterns - Clean Code
1
-
E-Book
1
-
Git Commands
1
-
HTML
19
-
Interview Prepration
2
-
Java Programming
0
-
JavaScript
12
-
Laravel PHP Framework
37
-
Mysql
1
-
Node JS
1
-
Online Business
0
-
PHP
28
-
Programming
8
-
Python
12
-
React Js
19
-
React Native
1
-
Redux
2
-
Rust Programming
15
-
SEO - Search Engine Optimization
1
-
Tailwind CSS
1
-
Typescript
10
-
Uncategorized
0
-
Vue JS
1
-
Windows Operating system
1
-
Woocommerce
1
-
WordPress Development
2
Tags
- Artificial Intelligence (AI)
- Bash Scripting
- Business
- C
- C Programming
- C-sharp programming
- C++
- Code Editor
- Computer Engineering
- CSS
- Data Structure and Algorithm
- Database
- Design pattern
- Express JS
- git
- Git Commands
- github
- HTML
- Java
- JavaScript
- Laravel
- Mathematics
- MongoDB
- Mysql
- Node JS
- PHP
- Programming
- Python
- React Js
- Redux
- Rust Programming Language
- SEO
- TypeScript
- Vue JS
- Windows terminal
- Woocommerce
- WordPress
- WordPress Plugin Development