我从未使用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"
]
}
最佳答案
这很可能是webpack-dev-server
的请求(也许 hot module replacement
功能已启用,不确定,也许是其他原因)。如果我没记错的话,Create-React-App 在开发模式下使用它(抱歉,没有经常使用它)。所以我相信这很好,但不确定这 600MB 的内存使用是否与此相关。
我的个人旁注:我总是发现像 Create-React-Apps 这样的引导工具对于初学者来说是一件坏事,因为很难理解幕后发生的事情。我的建议 - 要么深入研究 create-react-app 在底层使用什么来更好地理解堆栈,要么从头开始创建你的 React 应用程序,这一点也不难,而且在我看来更好。您可能只需要 node
+ webpack
+ react
关于javascript - React - 无限循环 xhr sockjs-node,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54749837/