我是react和firebase的新手。我正在尝试更改signInWithEmailAndPassword().then()中的isLoggedIn的值。但是我不能这样做,虽然已经调用了setIsLoggedIn(true),但它返回false。 import React, { useState, useContext } from 'react';
import { Link } from 'react-router-dom';
import fire from '../config/fire';
import { useHistory, u
我似乎无法获得对reactjs登录组件的测试。我只使用反应测试库而不是酶。
我想测试三件事:
,即单击signIn一次,axios调用使用模拟的ajax ,可以使用useState设置值,并检查在成功登录后呈现的页面具有文本的设置。
上述任何一项都不起作用。我一直在研究不同的问题,例如这个expect(signIn).toHaveBeenCalledTimes(1)返回:
Expected number of calls: 1
Received number of calls: 0
其他情况下,它会引发错误:无法找到给定节点的“窗口”对象。用于此:
const button =
我正在尝试为我的组件创建一个SessionProvider来避免全局的propdrilling和hold session。 但是它说useSession不是一个函数,是什么给出的呢? contexts\SessionContext.js: TypeError: (0 , _hooks_useSession__WEBPACK_IMPORTED_MODULE_2__.useSession) is not a function 我的自定义钩子(useSession.js): import { useState } from 'react'
function useSession(