1 | import * as React from 'react';
|
2 |
|
3 | /** As `React.useEffect` but pass origin value in callback and not need care deps length change. */
|
4 | export default function useEffect(callback, deps) {
|
5 | var prevRef = React.useRef(deps);
|
6 | React.useEffect(function () {
|
7 | if (deps.length !== prevRef.current.length || deps.some(function (dep, index) {
|
8 | return dep !== prevRef.current[index];
|
9 | })) {
|
10 | callback(prevRef.current);
|
11 | }
|
12 | prevRef.current = deps;
|
13 | });
|
14 | } |
\ | No newline at end of file |