1 | "use strict";
|
2 |
|
3 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
4 | Object.defineProperty(exports, "__esModule", {
|
5 | value: true
|
6 | });
|
7 | exports.default = useEffect;
|
8 | var React = _interopRequireWildcard(require("react"));
|
9 |
|
10 | function 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 |