- The React Workshop
- Brandon Richey Ryan Yu Endre Vegh Theofanis Despoudis Anton Punith Florian Sloot
- 196字
- 2021-06-11 18:28:33
Introduction
In the previous chapters, while building our components, we have used lifecycle methods multiple times without knowing it. For example, we have used the constructor() and render() methods in every class component we have built so far. We did not call or overwrite these methods specifically but React has behind-the-scenes functionality for performing this.
In this chapter, we will talk a little bit about what that means and explore the different methods, where they fire off during building a component, mounting them onto the Document Object Model(DOM), rendering them, and then updating them beyond that. You can also implement events that need to occur when a component is removed from the DOM using the unmount lifecycle method.
It's worth noting, however, that you cannot overwrite or call lifecycle methods explicitly in functional components; only class-based components have this functionality. You cannot override them because, being functions, they lack the ability that classes in JavaScript have; classes can define functions on each inpidual instance. There is no inheritance or properties; the functional component just runs the code on render.
Let's start off the chapter with an overview of the component lifecycle methods in class components.
- Docker技術入門與實戰(zhàn)(第3版)
- Power Up Your PowToon Studio Project
- 面向STEM的Scratch創(chuàng)新課程
- Java軟件開發(fā)基礎
- Highcharts Cookbook
- Learning Salesforce Einstein
- 從0到1:Python數據分析
- iPhone應用開發(fā)從入門到精通
- 響應式Web設計:HTML5和CSS3實戰(zhàn)(第2版)
- 動手打造深度學習框架
- SpringBoot從零開始學(視頻教學版)
- Photoshop CC移動UI設計案例教程(全彩慕課版·第2版)
- 邊玩邊學Scratch3.0少兒趣味編程
- JavaScript前端開發(fā)基礎教程
- Python深度學習:基于PyTorch