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

เริ่มต้นใช้งาน IPFS ด้วย Docker

สวัสดีครับ ในบทความนี้ผมจะอธิบายการใช้งาน IPFS ด้วย Docker ซึ่งการใช้งาน IPFS ด้วย Docker นั้นเป็นแนวทางนึงในการใช้งาน IPFS สําหรับใครที่อยากจะติดตั้งบนเครื่องก็สามารถอ่านเพิ่มเติมได้จาก Document ของ IPFS ได้เลยครับ แต่โดยส่วนตัวของผมนั้น ผมชอบที่จะใช้ผ่าน Docker เนื่องจากไม่ต้องติดตั้ง IPFS บนเครื่องของเรา ถ้าใครยังไม่รู้จัก Docker สามารถไปอ่านบนความเก่าๆได้ครับที่นี่ https://thiti.dev/tags/docker

disable enable taskbar raspberry pi

วิธีเอา taskbar ของ raspberry pi ออก คือ ให้ย้ายไฟล์ "panel" ไปไว้ใน path อื่น โดยปกติไฟล์ "panel" จะอยู่ใน path "~/.config/lxpanel/LXDE/panels"

วิธีออกแบบระบบ โซล่าเซลล์

ในบทความนี้เป็นเรื่องเกี่ยวกับการออกแบบและคํานวณระบบโซล่าเซลล์ ซึ่งจะหาว่าถ้าเราใช้อุปกณ์ไฟฟ้าเท่านี้เราจะใช้โซล่าเซลล์ เท่าไร แบตเตอรรี่เท่าไร


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

Build with ❤️ and Astro.

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