首页 > TAG信息列表 > safeEffect

react hook 实现use-watch

import { useEffect, useRef } from 'react'; const defaultCompare = (prev, next) => prev === next; export const useWatch = ( callback, value, { initialValue = '', compare = defaultCompare } = {}, ) => { const prevValue = us