I got a custom hook which return a function
export function useMyCustomHook = (dispatch) => () => {... some things with dispatching to store };
I'm trying to use the return value like this in a jest test:
const result = renderHook(() => useMyCustomHook(useDispatch()));
console.log(result.current);
but result.current is undefined. So how can I actually get the return value?
According to react-hooks-testing-library renderHook returns an object with result, so to access it:
const { result } = renderHook(() => useMyCustomHook(useDispatch()));
console.log(result.current);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With