ReactJS lifecycle method inside a function Component

前端 未结 8 593
一生所求
一生所求 2020-11-30 19:28

Instead of writing my components inside a class, I\'d like to use the function syntax instead.

How do I override componentDidMount, componentWillM

8条回答
  •  无人及你
    2020-11-30 20:13

    According to the documentation:

    import React, { useState, useEffect } from 'react'
    // Similar to componentDidMount and componentDidUpdate:
    
    useEffect(() => {
    
    
    });
    

    see React documentation

提交回复
热议问题