UNPKG

678 BJavaScriptView Raw
1"use strict";
2
3var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4Object.defineProperty(exports, "__esModule", {
5 value: true
6});
7exports.default = useEffect;
8var React = _interopRequireWildcard(require("react"));
9/** As `React.useEffect` but pass origin value in callback and not need care deps length change. */
10function useEffect(callback, deps) {
11 var prevRef = React.useRef(deps);
12 React.useEffect(function () {
13 if (deps.length !== prevRef.current.length || deps.some(function (dep, index) {
14 return dep !== prevRef.current[index];
15 })) {
16 callback(prevRef.current);
17 }
18 prevRef.current = deps;
19 });
20}
\No newline at end of file