useCompose icon indicating copy to clipboard operation
useCompose copied to clipboard

Added onDispose Functionality and Modified deps Type to Array in useEffect

Open psyrenpark opened this issue 5 months ago • 1 comments

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")
        }
    )

psyrenpark avatar Mar 05 '24 02:03 psyrenpark