0
2

More than 3 years have passed since last update.

React入門(コンポーネントのライフサイクル)

Posted at

Mountingは初期値
Unmountingは初期値から変更された値

useEffect

import { useEffect } from 'react';

useEffect(() => {
  // MountingとUnmountingに呼ばれる
})

useEffect(() => {
  // Mountingの時に呼ばれる
}, [])

useEffect(() => {
  // Mountingと引数の時に呼ばれる
}, [引数])

useEffect(() => {
    // Mountingの時に呼ばれる
  return () => {
    //Unmountingが呼び出される
   }
})

おまけ

styled-componentsの書き方
yarn add styled-componentsでインストール出来ます
import styled from 'styled-components';


const EditBtn = styled.button`
  margin: 0;
  padding 0;
`

コンポーネントにCSSをつけることができます。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2