UNPKG

phaser-jsx

Version:
21 lines 887 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useEffect = useEffect; var helpers_1 = require("../helpers"); /** * A hook that lets you run a side effect after render. * * The callback runs after each render where the dependencies have changed. * If the callback returns a function, that function is called as cleanup * before the next effect run or when the context is destroyed. * * @param callback - The effect to run. May return a cleanup function. * @param deps - Optional dependency array. If omitted, runs after every render. * Pass an empty array to run only once on mount. */ function useEffect(callback, deps) { var context = (0, helpers_1.getRenderContext)(); var key = context.getNextEffectIndex(); context.pendingEffects.push({ key: key, callback: callback, deps: deps }); } //# sourceMappingURL=useEffect.js.map