Lifecycle Methods ของ React Component

11 Feb 2018,
Share: 

มาดู Lifecycle ของ Component กันหน่อยครับ ว่าตั้งแต่ Component เกิดขึ้นมาจนถูกถอดออกจากเว็บ มันเกิดอะไรขึ้นบ้าง

ใน React.component ที่เรา Extends มาตอนเราสร้าง Component จะ Method ที่จะถูกเรียกตาม Lifecycle ดังนี้

componentWillMount()

เกิดขึ้นก่อนที่ component จะถูก render ขึ้นมา

componentDidMount()

เกิดขึ้นหลังจากที่ component ได้ถูก render แล้ว

componentWillReceiveProps()

เกิดขึ้นหลังจากที่ component ได้รับ props ค่าใหม่

componentWillUpdate()

เกิดขึ้นก่อนที่ component จะถูก render ใหม่ หลังจากที่ได้รับ props ใหม่

componentDidUpdate()

เกิดขึ้นหลังที่จาก component ถูก render ใหม่

componentWillUnmount()

เกิดขึ้นก่อนที่ component จะถูกเอาออกจาก DOM

React Lifecycle Methods

Image

Suggestion blogs

Fail2Ban แบน ip ผู้ที่พยายามสุ่มรหัส login

server ที่ online อยู่บน internet เพื่อเปิดเป็น web server หรือ อื่นๆ จําเป็นจะต้องเปิดใช้งาน SSH เพื่อ remote เข้าไปควบคุมเครื่อง server จากที่ใดก็ได้ผ่านทาง internet ซึ่งจะใช้ user และ password ในการ login เข้าใช้งาน

Unbox ไฟฉาย Nitecore TIP 2017

ไฟฉาย Nitecore รุ่น TIP Version 2017 เป็นไฟฉายรุ่นที่ที่มีความสว่างสูงสุด 360 Lumens แสงพุ่งไกลถึง 74 เมตร จุดเด่นของรุ่นนี้คือ เป็นไฟฉายที่มีขนาดเล็กแต่ให้ความสว่างสูง มีแบตเตอรี่ภายใน คุณสมบัติโดยทั่วไปดังนี้

แก้ปัญหา Preset ใน Premiere Pro CS6 ไม่ครบ

กรณีที่เราลง Adobe Premiere Pro CS6 หลังจาก Crack แล้ว เมื่อเปิดโปรแกรมขึ้นมาใช้งาน Preset จะขึ้นไม่ครบ HDV ไม่ขึ้น ดังรูป


Copyright © 2019 - 2025 thiti.dev |  v1.54.0 |  Privacy policy | 

Build with ❤️ and Astro.

Github profile   Linkedin profile   Instagram   X profile   Nostr   Youtube channel   Telegram   Email contact   วงแหวนเว็บ