我遇到了问题,在多个文件中使用钩子,并且在第一个异步方法完成之前为useEffect调用了两次钩子(这应该阻止第二个钩子调用,但它不是)。见下文2种情况:const { context, state } = useLobby(); // Hook is called here 1st, which will do the initialroom id
const context = React.useMemo(() =&g
在我的React应用程序中,我使用的是非空断言(!)告诉TS,来自useContext钩子的值不是null。// context.ts user: User | null; // User type is defined elsewhere, has 'id' and'email' user: null,