我已经将create-react-app与electro-forge应用程序绑定在一起,现在我需要以某种方式指定从 CRA 生成的用于打包的构建文件夹。该文件夹也应该被提供。
电子锻造可以实现这样的事情吗?
我正在使用 antd 和 create-react-app 来创建我的应用程序。
我遵循这个示例:https://github.com/ant-design/antd-init/tree/master/examples/customize-antd-theme
这里他们给出了使用 webconfig 的示例。当我尝试更换相同的颜色时,我无法更改原色。有人能告诉我如何在 create-react-app 中做同样的事情吗?
我正在将我的 React 应用程序从自我管理的 Webpack 构建迁移到create-react-app基于 Webpack 的构建。我的样式未正确编译,例如,在我的主渲染方法中:
return (
<Grid>
<Row style={headerStyle}>
<Col xs={12}>
<h1 style={{'text-align': 'center', 'color': 'white'}}>
Dashboard v0.3
</h1>
</Col>
</Row>
</Grid>
)
Run Code Online (Sandbox Code Playgroud)
我得到了错误Warning: Unsupported style property text-align. Did you mean textAlign?。诸如此类的错误还有很多。任何帮助,将不胜感激。
我有项目使用create-react-app和typescript
我希望能够WebWorker执行一些昂贵的任务。但我还没有找到任何解决方案来启用它。
我浏览了一些图书馆:
你有什么想法?
提前致谢!
我想要一个 .env 文件中维护的可配置默认颜色变量。例如,我想要一个 .env 文件,其中包含
PRIMARY=red
Run Code Online (Sandbox Code Playgroud)
和一个_variables.scss包含
$primary: ${process.env.PRIMARY}
Run Code Online (Sandbox Code Playgroud)
和一个 SCSS 文件,其中包含
.my-class { color: $primary; }
Run Code Online (Sandbox Code Playgroud)
以及我使用包含的样式表的组件
import './MyComponent.scss';
Run Code Online (Sandbox Code Playgroud)
这可能吗?如果没有,我会有什么选择?
我在 lerna 包下有 2 个项目。其中一个是一个包,另一个是一个cra网站。当我在每个包下执行“yarn start”时,我可以看到构建文件夹和分别在开发服务器中加载的网站:
问题是当我从根(lerna 根)执行“纱线启动”时,执行完成但第二个包中的站点没有启动。
"start": "lerna run --parallel start"
我也试过 exec ,但仍然没有。
..\vtest\src\client>yarn start
yarn run v1.22.4
$ lerna exec --parallel -- yarn start
lerna notice cli v3.22.0
lerna info Executing command in 2 packages: "yarn start"
webcore: $ tsc
websample: $ react-scripts start
websample: i ?wds?: Project is running at http://192.168.1.121/
websample: i ?wds?: webpack output is served from
websample: i ?wds?: Content not …Run Code Online (Sandbox Code Playgroud) 我在使用开箱即用create-react-app my-app --template typescript项目无法识别任何元素的VSCode 中遇到问题。我不断收到错误无法找到名称 xxx,其中 'xxx' 是我在 JSX 中使用的任何 HTML 元素。
有趣的是,该项目最初将在零编辑的情况下运行。一旦我真正进入App.tsx并更改任何内容或创建一个非常基本的新组件,它就会中断。
这是我尝试按照来自 TypeScript 手册 Github 的本教程制作的一个非常基本的组件。
// src/components/Hello.tsx
import React from 'react';
export const Hello = () => {
return <h1>Hello < /h1>;
};
Run Code Online (Sandbox Code Playgroud)
该项目再次直接从推荐的 TypeScript 模板创建,使用create-react-app my-app --template typescript. 未编辑任何文件。
它带着自己的tsconfig.json准备出发了。
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": …Run Code Online (Sandbox Code Playgroud) 我有旧项目可以使用
<img src={require('./logo.svg')} className="App-logo" alt="logo" />
Run Code Online (Sandbox Code Playgroud)
但是我用 create-react-app 创建了一个新项目并且 require('...') 不再有效。好像新版本不支持require了,怎么动态加载图片呢?
旧项目 package.json
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.3"
}
Run Code Online (Sandbox Code Playgroud)
新建项目 package.json
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.0",
"web-vitals": "^0.2.4"
}
Run Code Online (Sandbox Code Playgroud) 当我运行时,npx create-react-app appname我收到以下错误消息:
You are running `create-react-app` 4.0.0, which is behind the latest release (4.0.1).
We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
npm ERR! code 1
npm ERR! path /Users/hat/Projects/youtube/react
npm ERR! command failed
npm ERR! command sh -c create-react-app loll …Run Code Online (Sandbox Code Playgroud) 我通过创建了一个新的 CRA 项目yarn create react-app my-app --template typescript,在运行开发服务器 ( yarn start)时出现以下错误:
src/App.tsx
Line 5:24: Parsing error: Unexpected token, expected ";"
3 | import "./App.css";
4 |
> 5 | const _window = window as any;
| ^
6 |
7 | const App: FC<{}> = () => {
8 | return <div />;
Run Code Online (Sandbox Code Playgroud)
我只在 cra 服务器中收到错误,IDE Typescript 引擎认为代码没有问题。什么可能导致这种情况?
我的 package.json:
{
"name": "xxx",
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.1.4",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10", …Run Code Online (Sandbox Code Playgroud) create-react-app ×10
reactjs ×6
typescript ×4
javascript ×2
antd ×1
ecmascript-6 ×1
electron ×1
image ×1
lerna ×1
node-sass ×1
node.js ×1
npm ×1
npx ×1
requirejs ×1
web-worker ×1
webpack ×1