You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
467 B
15 lines
467 B
import * as React from 'react';
|
|
/** As `React.useEffect` but pass origin value in callback and not need care deps length change. */
|
|
|
|
export default function useEffect(callback, deps) {
|
|
var prevRef = React.useRef(deps);
|
|
React.useEffect(function () {
|
|
if (deps.length !== prevRef.current.length || deps.some(function (dep, index) {
|
|
return dep !== prevRef.current[index];
|
|
})) {
|
|
callback(prevRef.current);
|
|
}
|
|
|
|
prevRef.current = deps;
|
|
});
|
|
} |