这是我定制的钩子:
export function useClientRect() {
const [scrollH, setScrollH] = useState(0);
const [clientH, setClientH] = useState(0);
const ref = useCallback(node => {
if (node !== null) {
setScrollH(node.scrollHeight);
setClientH(node.clientHeight);
}
}, []);
return [scrollH, clientH, ref];
}
}
我希望每次调用它时,它都返回我的值。例如:
jest.mock('useClientRect', () => [300, 200, () => {}]);
我怎么才能做到呢?