Lifecycle Methods ของ React Component

11 Feb 2018

Share to:

มาดู 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

ตัวหารร่วมมาก และการนำไปใช้

ตัวหารร่วมมาก (ห.ร.ม.) คือ ตัวหารร่วม (หรือตัวประกอบร่วม) ที่มีค่ามากที่สุด ที่นำไปหารจำนวนนับชุดใด(ตั้งแต่สองจำนวนขึ้นไป) ได้ลงตัว ต่อไปนี้เราจะเรียกว่าการหา ห.ร.ม. เช่น ห.ร.ม. ของ 8 และ 12 คือ 4 เพราะ 4 คือจำนวนที่มากที่สุดที่หารทั้ง 8 และ 12 ได้ลงตัว

ESP8266 ควบคุม i/o ผ่าน web (Access point)

ในบทความนี้ผมจะอธิบายถึงวิธีการทําให้ ESP8266 เป็น Access point ให้อุปกรณ์อุปกรณ์อื่นๆ ที่เชื่อมต่อ wifi ได้ เช่น computer, smart phone ฯลฯ มาเชื่อมต่อกับ SEP8266 แล้วควบคุม i/o ปิด/เปิด LED ผ่านเว็บ ด้วยวิธีส่งข้อมูลผ่าน HTTP_GET เช่น

วิธีทําให้ ubuntu เห็น NTFS และ ทํา auto mount

วิธีทําให้ ubuntu เห็น NTFS และ ทํา auto mountในบทความนี้ผมจะมาแนะนําวิธีการทําให้ ubuntu ใช้งาน file system ที่เป็นแบบ NTFS ได้ และจะทําการ mount drive โดยอัตโนมัติ มาเริ่มกันเลยครับ


Copyright © 2019 - 2024 thiti.dev |  v1.39.0 |  Privacy policy | 

Build with ❤️ and Astro.

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