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

ปัญหาการใช้งาน async, await ใน Loop ของ Javascript

สวัสดีครับ ในบทความนี้เราจะมาเรียนรู้ปัญหาการใช้งาน Async, Await กับ Loop ชนิดต่างๆใน Javascript เมื่อเราใช้ Async, Await ใน Loop แต่ละชนิดจะให้ผลออกมาไม่เหมือนกัน Loop บางชนิดจะ Await รอในแต่ละครั้งของการวน Loop แต่สําหรับ Loop บางชนิดจะไม่รอ ดังนั้นมาดูกันครับว่า Loop แต่ละชนิดมีการทํางานกับ Async, Await อย่างไรบ้าง ดังนี้ครับ

Props และ State ใน React

สวัสดีครับวันนี้เราจะมาดูเรื่องของ Props และ State ซึ่งเป็นเรื่องที่ค่อนข้างสําคัญ และใช้งานบ่อยใน React ผมจะอธิบาย และสอนการใช้งานไปที่ละตัวนะครับ ดังนี้

pwd command การดู path ปัจจุบันใน ubuntu

ในการใช้ Shell command บางครั้งเราต้องการที่จะดู path บัจจุบันที่เราเข้ามา ให้เราใช้คําสั่งนี้


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

Build with ❤️ and Astro.

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