配列がないuseEffect()
場合は、最初のレンダリングでのみコールバックを実行します。
useEffect(()=>{},[])
次に、との違いは何ですかuseEffect()
。
私はこれの間を意味します:
function myComponent() {
// some states, variables
useEffect(() => {
// do something on mount <= this is my current concern.
}, [/* empty */]);
// return Element ...
}
この:
function myComponent() {
// some states, variables
// do something on mount <= this is my current concern.
// return Element ...
}