我正在构建一个带有REACT和expressJS服务器的sudoku应用程序。我希望板加载上次保存的板,每次页面被刷新,这样用户就不会丢失他们的数据。
我正在发送一个v managed to send a post request to the seerver and send the current board, I store the current board in an array (at the server) and i manage to update it every POST request so that everytime a change is accuring wi
在我的react项目中,每当一些reducer状态属性发生变化时,我都会更新数据库。 useEffect(() => {
//Updating db here
}, [reducerState.table, reducerState.order, reducerState.bill, reducerState.liveCart, reducerState.occupency]) 当我重新加载页面时,我需要将其设置为初始状态,所以我使用另一个类似于下面的useEffect useEffect(() => {
//making db call to get the
我想运行我从另一个数据(API)中解构的数据(所有级别),并将其显示到dom中,它可以工作,但当我刷新页面时,我得到一个空数组。 使用下面的代码,我获得了数据 //Function to fetch the data from the API
const GetCourses = async () => {
const response = await axios.get(url)
const {data} = response;
return data;
}
//UseEffect to run the function on every rende
这是我的前端代码.js
import React, { useState, useEffect } from "react";
import Navbar from "../Navbar/Navbar";
import Axios from "axios"; //axios library to make requests to api
import "./Stats.css";
function Stats() {
const [customerList, setCustomerList] = useState([]);
我有这样一个组件
function App() {
const mounted = useRef()
useLayoutEffect(() => {
mounted.current = true
return () => {
console.log('unmounted') // this does not get called when I unmount the component
mounted.current = false
}
}, [])
if (mounted.current) {