【发布时间】:2019-12-25 08:22:10
【问题描述】:
我有一个返回函数的自定义钩子
export function useMyCustomHook = (dispatch) => () => {... some things with dispatching to store };
我正在尝试在开玩笑的测试中使用这样的返回值:
const result = renderHook(() => useMyCustomHook(useDispatch()));
console.log(result.current);
但result.current 未定义。那么如何才能真正得到返回值呢?
【问题讨论】:
-
你的钩子返回什么?
-
@AmitChauhan 钩子就在那里。我正在返回一个函数
标签: reactjs jestjs react-testing-library