Open
Description
Passing new props to rerender
doesn't work, please let me know if i'm doing anything wrong, thx
package.json
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
hook
export const useTriggerFocus = ({ condition = true, ref }: any): null => {
console.log(condition);
useEffect(() => {
const element = ref.current;
if (condition && element) {
element?.focus();
}
}, [ref, condition]);
return null;
};
test
it('triggers a change', () => {
const condition = false;
const focus = vi.fn();
const ref = {
current: {
focus,
},
};
const { rerender } = renderHook(() => useTriggerFocus({ condition, ref }));
rerender({ condition: true, ref: undefined });
rerender();
rerender();
rerender();
});
});
console
false
false
false
false
false
Metadata
Metadata
Assignees
Labels
No labels