https://create-react-app.dev/docs/adding-custom-environment-variables/中有一个声明 :
除 NODE_ENV 之外的任何其他变量都将被忽略,以避免意外暴露机器上可能具有相同名称的私钥。
在机器上公开可能具有相同名称的私钥是什么意思?我从这句话中什么也得不到。您能举例解释一下这个说法吗?先感谢您。
使用pnpm dlx和为 create-react 应用程序(版本 5.0.0)安装依赖项时pnpm import,我收到一条警告,提示应安装对等依赖项。React 的开发环境运行得很好。使用时不会出现此警告消息npx。除了安装对等依赖项之外,如何修复此警告消息?提前致谢。
我做了什么:
\npnpm dlx create-react-app ./temp-app\nRun Code Online (Sandbox Code Playgroud)\npnpm import package-lock.json\nRun Code Online (Sandbox Code Playgroud)\n\xe2\x80\x89WARN\xe2\x80\x89 Issues with peer dependencies found\n.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @testing-library/user-event\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 \xe2\x9c\x95 missing peer @testing-library/dom@>=7.21.4\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\xac react-scripts\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 \xe2\x9c\x95 missing peer typescript@"^3.2.1 || ^4"\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac eslint-config-react-app\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\xac @typescript-eslint/eslint-plugin\n \xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 \xe2\x9c\x95 missing peer typescript@"*"\n …Run Code Online (Sandbox Code Playgroud) 我想将 Emotion 与 CRA 一起使用,因此我按照文档安装了它,并尝试使用 css prop,如下例所示:
import { FC } from "react";
import { TypographyProps } from "./Typography.propTypes";
import * as styles from "./Typography.styles";
export const Typography: FC<TypographyProps> = ({
children,
}) => {
return <h1 css={styles.typography}>{children}</h1>;
};
Run Code Online (Sandbox Code Playgroud)
但没有成功。
通过检查代码,我发现了这一点:
<h1 css="You have tried to stringify object returned from `css` function.
It isn't supposed to be used directly (e.g. as value of the `className` prop),
but rather handed to emotion so it can handle it (e.g. as value of …Run Code Online (Sandbox Code Playgroud) 帮助我在创建react应用程序时安装react-pdf包(https://github.com/diegomura/react-pdf)。我无法更改 webpack.config。我按照用户 River Twilight 在这里找到的说明来执行此操作:How to update webpack config for a React Project Created using create-react-app?
根据安装react-pdf的说明
npm install process browserify-zlib stream-browserify util buffer assertconfig-override.js在项目根文件夹中创建const webpack = require("webpack");
module.exports = {
/* ... */
resolve: {
fallback: {
process: require.resolve("process/browser"),
zlib: require.resolve("browserify-zlib"),
stream: require.resolve("stream-browserify"),
util: require.resolve("util"),
buffer: require.resolve("buffer"),
asset: require.resolve("assert"),
}
},
plugins: [
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
process: "process/browser",
}),
]
/* ... */
}Run Code Online (Sandbox Code Playgroud)
但是 a) webstorm 发誓,b) 该项目不是由 …
我有一个A依赖于 package 的包B。我用来在本地yalc更新B和发布更改,以便A可以获取这些更改。
我可以看到更改已复制到 的文件夹中A,node_modules但是 webpack 似乎没有拾取它们。A在开发服务器中运行时,我仍然看到旧代码。重新启动开发服务器没有帮助。甚至yarn install --check-files没有帮助。唯一有帮助的就是用核武器摧毁整个系统node_modules并重新安装。
项目A是用以下命令创建的create-react-app
package.json有以下内容:
dependencies: {
...
@company_name/project_name: "file:.yalc@company_name/project_name"
... }
Run Code Online (Sandbox Code Playgroud)
我在用yarn 1.22
当我使用 npm start 运行 create React app 应用程序时,eslint 错误显示在我网站顶部的浏览器中。我希望在终端中看到这些警告和错误,但在实际网站中看不到,我该如何删除它?
包.json
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.11.0",
"react-dom": "^16.11.0",
"react-router-dom": "^5.1.2",
"react-scripts": "^5.0.0",
"react-transition-group": "^4.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint ."
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}, …Run Code Online (Sandbox Code Playgroud) 我想从生产版本中删除 data-testid,因此在产品版本中找不到这些属性特别是在这种情况下,我需要一些与 .tsx 文件一起使用的东西我知道如何使用组件中的函数删除它,但我认为应该有一种更聪明的方法来做到这一点。反应 cra 反应应用程序重新连线
我正在使用AWS ECS上的docker部署create-react-app。我正在使用dockerhub映像进行测试,该映像几乎是create-react-app的原始版本。启动任务时,它能够拉出容器映像,启动docker容器,但是它挂在运行react-scripts start上。我在容器日志中看到的全部是:
01:51:38 npm info it worked if it ends with ok
01:51:38 npm info using npm@2.15.11
01:51:38 npm info using node@v4.7.3
01:51:42 npm info prestart test-react@0.1.0
01:51:42 npm info start test-react@0.1.0
01:51:42 > test-react@0.1.0 start /usr/src/app
01:51:42 > react-scripts start
01:52:06 Starting the development server...
Run Code Online (Sandbox Code Playgroud)
它只是挂在那里,永远不会完成。但是,当我手动运行docker容器时,一切正常:
Starting the development server...
Compiled successfully!
The app is running at:
http://localhost:3000/
Run Code Online (Sandbox Code Playgroud)
我的Dockerfile是:
FROM node:4-onbuild
# Prepare app directory
RUN mkdir -p /usr/src/app
ADD . /usr/src/app
# Install dependencies
WORKDIR /usr/src/app
RUN …Run Code Online (Sandbox Code Playgroud) 我有React应用是通过用玩笑和酶进行create-react-app制作的
那么如何获取window.location.pathname测试文件内部的值?
这是我的规格
import React from 'react';
import MovieDetailsBox from '../../src/components/movie_single/MovieDetailsBox';
import { expect } from 'chai';
import { shallow } from 'enzyme';
import { movie_details } from '../../src/data/movies_details'
import { empty_user } from '../../src/helper/sessionHelper';
jest.mock('react-router');
describe('Test <MovieDetailsBox /> Component', () => {
let movie_details_props = {
movie: {...movie_details}
}
let user_props = {
}
const context = { router: { isActive: (a, b) => true } }
const wrapper = shallow(
<MovieDetailsBox movie={movie_details_props}
user={user_props}
currentPath={'/movie/68'}/>, { context …Run Code Online (Sandbox Code Playgroud)