useCompose
useCompose copied to clipboard
Added onDispose Functionality and Modified deps Type to Array in useEffect
Hello ~,
I needed an onDispose functionality within useEffect, so I've added it. Additionally, I have changed the type of deps to an array.
I would appreciate it if you could review them.
// example
/*
useEffect(()=>{
console.log("Call once")
},[])
*/
useEffect(onEffect = {
println("Call once")
})
/*
useEffect(()=>{
console.log("Call once")
return () => {
console.log("onDispose")
}
},[])
*/
useEffect(onEffect = {
println("Call once")
}, onDispose = {
println("onDispose")
}
)
/*
useEffect(()=>{
console.log("Call when the value of isOn changes")
return () => {
console.log("onDispose")
}
},[isOn, "SOME" ])
*/
useEffect(arrayOf(isOn,"SOME"),
onEffect = {
println("Call when the value of isOn changes [isOn] $isOn")
}, onDispose = {
println("onDispose")
}
)