useEffectDeep

same as useEffect but the dependencies array will recursively look down objects

Demo

Open console to see logs

Usage

import { useSignal } from "kaioken"
import { useEffectDeep } from "@kaioken-core/hooks"

const context = useSignal({
  count: 0,
  name: "",
})

useEffectDeep(() => {
  console.log(
    "I will trigger when count and name change",
    "despite context being the same object reference"
  )
}, [context.value])

const onClick = () => {
  context.value.count += 1
  context.notify()
}

const onInput: ElementProps<"input">["oninput"] = (e) => {
  context.value.name = e.target.value
  context.notify()
}

Type Declaration

import { const useEffectDeep: (callback: () => void | (() => void), deps: unknown[]) => voiduseEffectDeep } from "@kaioken-core/hooks"