-- Compiled with roblox-ts v3.0.0 local TS = _G[script] local useHookState = TS.import(script, script.Parent.Parent, "topo").useHookState local Phantom = TS.import(script, TS.getModule(script, "@rbxts", "phantom").src) --[[ * * * @param callback - The function to memoize. * @param dependencies - An array of values to compare against the previous dependencies. * @param discriminator - An optional value to additionally key by. * @param key - An automatically generated key to store the memoized value. * @metadata macro ]] local function useEffect(callback, dependencies, discriminator, key) local _key = key assert(_key ~= "" and _key, "Attempted to use useEffect without a key.") local storage = useHookState(key, discriminator) if not dependencies or not storage.dependencies or not Phantom.Array.equals(storage.dependencies, dependencies) then if storage.cleanup then storage.cleanup() end storage.cleanup = callback() storage.dependencies = dependencies end end return { useEffect = useEffect, }