useEffect, useLayoutEffect and useInsertionEffect
Allows to run side effects after rendering
Syntax
Where :
effectCallback
: Function that is executed one or more times according tooptionalArgumentList
,effectCallback
can return a function that will be executed only ifeffectCallback
is executed again or the webcomponent is unmounted.optionalArgumentList
: Array of arguments that controls the execution ofeffectCallback
, if an argument ofoptionalArgumentList
changes it will trigger thateffectCallback
is executed again without first cleaning the effects subscribed by the previous execution.
Example
useLayoutEffect
useLayoutEffect replicates the logic of useEffect but with synchronous execution after rendering.
useInsertionEffect
useLayoutEffect replicates the logic of useEffect but with synchronous execution before rendering.
Last updated