我从来没有使用react.js(Create-React-App)托管网站。
我已经使该网站在线,但是我尚未打开API。
我不知道为什么我会像这样自动循环xhr socketjs-nodes:
即使我只使用React.js进入1个项目并获得了接近600MB的物理内存使用量,这都是因为这个xhr吗?
这是我的package.json:
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.12",
"@fortawesome/free-brands-svg-icons": "^5.6.3",
"@fortawesome/free-solid-svg-icons": "^5.6.3",
"@fortawesome/react-fontawesome": "^0.1.3",
"@material-ui/core": "^3.7.1",
"@material-ui/icons": "^3.0.1",
"axios": "^0.18.0",
"forever": "^0.15.3",
"history": "^4.7.2",
"js-cookie": "^2.2.0",
"jsonwebtoken": "^8.4.0",
"jwt-decode": "^2.2.0",
"moment": "^2.23.0",
"prop-types": "^15.6.2",
"querystring": "^0.2.0",
"react": "^16.7.0",
"react-addons-update": "^15.6.2",
"react-cookie": "^3.0.8",
"react-dom": "^16.7.0",
"react-image-gallery": "^0.8.12",
"react-images": "^0.5.19",
"react-redux": "^6.0.0",
"react-router-dom": "^4.3.1",
"react-scripts": "2.1.2",
"react-select": "^2.3.0",
"react-slick": "^0.23.2",
"redux": "^4.0.1",
"redux-devtools-extension": "^2.13.7",
"redux-thunk": "^2.3.0",
"slick-carousel": "^1.8.1",
"typeface-roboto": "0.0.54"
},
"scripts": {
"start": "PORT=40000 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
答案 0 :(得分:1)
这很可能是webpack-dev-server
的请求(也许hot module replacement
功能已启用,不确定,也许还有其他原因)。如果我没记错的话(很抱歉,没有使用太多),Create-React-App在开发模式下会在后台使用它。因此,我相信这很好,但是不确定那600MB的内存使用量是否与此有关。
我的个人旁注:我总是发现诸如Create-React-Apps之类的引导工具对初学者来说是一件坏事,因为很难理解幕后发生的事情。我的建议-深入研究如何在幕后使用create-react-app更好地了解堆栈,或者只是从头开始创建您的react应用程序,这一点都不难,而且IMO更好。您可能只需要node
+ webpack
+ react
答案 1 :(得分:0)
我遇到了类似的问题,在我的情况下,错误出在我的代码中,其中两个资源之间存在循环,其中一个资源“B”是从资源“A”请求的,而在“B”中它请求“A”获取它的一个元素。