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をつけることができます。