我使用以下代码从react应用程序的API中获取数据。获取数据需要时间,因此变量得不到值。我如何在这里执行异步可观察的等待操作?我是个新手,还不知道该怎么做。
import React from 'react';
import ReactDOM from 'react-dom';
import { createStore } from 'redux';
import App from './App';
impo
import React, { useState, useEffect } from "react";
import { checkRef } from "./firebase";
function Dashboard() {
const [count, setCount] = useState([]);
let hi = [];
// Similar to componentDidMount and componentDidUpdate:
useEffect(() => {
checkRef.on("value"
在我的react组件中,我在控制台中遇到了以下问题
index.js:1 Warning: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render. at Id (http://localhost:3000/main.82c936520e7a7
我正在尝试将问题和相关选项的集合推送到名为‘quizze’的firebase ref中。当单击submit时,我在控制台中得到以下内容。
Uncaught Error: Firebase.push failed: first argument contains an invalid key ($$typeof) in property 'quizzes.questions.0'. Keys must be non-empty strings and can't contain ".", "#", "$", "/
我目前已经用firebase初始化了一个React应用。在应用程序中,我使用react-router-dom创建了一个开放登录路由和一个私有Home路由。我的app.js是这样的: App.js: import React from 'react'
import { BrowserRouter, Switch, Route } from 'react-router-dom'
import Login from './pages/Login'
import Home from './pages/Home'
import Priva
您能解释一下关于内部状态和外部状态数据的不同之处吗?
constructor(){
this.data1 = "this is data 1",
this.state = {
this.data2 = "this is data 2"}
}
因此,如果我在componentDidMount中使用data 2,或者在render函数中没有任何条件代码,它会抛出描述React的错误,不能允许无限循环bla,但是如果我在componentDidMount中或在呈现函数中使用data1,它就会完美地工作。那么,difernet是什么?我是否应该使用data1来使我的自