标签: create-react-app

有没有人能够用语义ui设置创建反应应用程序?

如果是这样,请分享文件夹结构(语义路径在哪里)和导入组件的示例.

reactjs semantic-ui create-react-app

8
推荐指数
2
解决办法
6162
查看次数

Create-React-App无法编译| 导入/第一个错误

我目前正在为我的个人网站使用Create-React-App.每次运行时我都会遇到以下错误:

./src/~/react-router-dom/es/index.js
 Line 3:   Import in body of module; reorder to top  import/first
 Line 5:   Import in body of module; reorder to top  import/first
 Line 7:   Import in body of module; reorder to top  import/first
 Line 9:   Import in body of module; reorder to top  import/first
 Line 11:  Import in body of module; reorder to top  import/first
 Line 13:  Import in body of module; reorder to top  import/first
 Line 15:  Import in body of module; reorder to top  import/first
 Line …
Run Code Online (Sandbox Code Playgroud)

import importerror reactjs create-react-app react-router-dom

8
推荐指数
3
解决办法
1万
查看次数

如何在React应用程序中包含第三方js库

我是React的新手,我正在寻找React等效的JQuery方法,在我的应用程序中包含分析.

通常我会:

  1. 在html页面上包含第三方库.很容易进入index.html页面,但我不知道这是否是最佳做法.

    <script src="http://path/to/script/utag.js" />

  2. 然后我可以与库交互,只要它已经加载,我可以使用JQuery window.load验证.这个脚本在普通的html页面上运行正常,但我试图在我的反应应用程序中找到相同的最佳实践方法.我不想介绍jquery,目前我的React容器会告诉我,如果我尝试utag在函数中引用,那么utag没有定义.

    <script> $(window).load(function() { utag.link({ "event_name" : "locale_select", "language" : utag_data.language, "currency" : utag_data.currency } ); }); </script>

我是React的新手,所以任何帮助都会很棒.我知道我的项目没有使用webpack,它使用的是react-scripts并且是使用create-react-app实用程序启动的.

javascript reactjs create-react-app

8
推荐指数
1
解决办法
4986
查看次数

在 docker 容器外编辑文件时,React Webpack 不会重建(在 mac 上)

我已经使用 create-react-app 在 docker 容器中创建了一个 React 应用程序。当我在容器内编辑 App.js 时,应用程序会自动重新构建并重新加载浏览器。但是当我在容器外(在主机上)编辑文件时,它不会被重建。

这是一个 webpack/watch 问题 - 但也许也与在 mac 上运行 docker 有关?任何帮助,将不胜感激。

我认为这种事情对于开发人员设置来说是很正常的(即 - 使用 docker 创建您的构建环境,但使用安装作为实际代码)。

这是我正在使用的 Github 存储库。

macos docker reactjs webpack create-react-app

8
推荐指数
2
解决办法
2850
查看次数

在create-react-app中启用CORS

我需要在使用create-react-app实用程序创建的React中使用'CORS'节点模块.

由于它是一个实用程序,我无法调整内部并将'CORS'注入预先配置的'EXPRESS'模块.

我们怎样才能做到这一点?

cors express create-react-app

8
推荐指数
2
解决办法
6394
查看次数

在src目录中创建React App(TypeScript)自动生成react-app-env.d.ts

内容:

我只是将一个应用从移植create-react-app-typescript到create-react-app。在结构相同但不同的应用程序中,我执行了相同的步骤。

脚步:

npm uninstall react-scripts-ts
npm install react-scripts
npm install --save typescript @types/node @types/react @types/react-dom @types/jest
Run Code Online (Sandbox Code Playgroud)

详细步骤

第二个应用程序特有的问题:

  • Type error: Cannot compile namespaces when the '--isolatedModules' flag is provided. TS1208
  • Generated file src/react-app-env.d.ts

Assumption:

The generated file src/react-app-env.d.ts causes the --isolatedModules error.

Actual Question:

How do I prevent react-scripts from generating the src/react-app-env.d.ts file upon react-scripts start?

typescript create-react-app

8
推荐指数
2
解决办法
5283
查看次数

CRA 2.0 w / typescript由于实现限制而覆盖了我的tsconfig.json

我正在尝试安装tailwindcss并在全新的CRA 2.0(特别是2.1.2)中使用打字稿。

我无法在没有CRA覆盖的情况下覆盖“ isolatedModules”:true标志。

我尝试通过从modules.export更改导出样式并将配置强制为false而不是删除它来解决此问题。我读到,您还可以创建一个单独的tsconfig.json,扩展您的旧tsconfig.json并覆盖那里的更改,但这似乎很麻烦。

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "noEmit": true,
    "jsx": "preserve",
    "isolatedModules": true
  },
  "include": [
    "src",
    "postcss.config.js"
  ]
}
Run Code Online (Sandbox Code Playgroud)

postcss.config.json

const tailwindcss = require('tailwindcss');
module.exports = {
  plugins: [tailwindcss('./tailwind.config.js'), require('autoprefixer')]
};
Run Code Online (Sandbox Code Playgroud)

这是我的npm开始吐出来的东西

The following changes are being made to your tsconfig.json file:
  - compilerOptions.isolatedModules must be true (implementation limitation)
Run Code Online (Sandbox Code Playgroud)

我可以看到我的应用程序可以编译,工作,然后绘制到页面上,然后将其替换为显示错误的红色错误框

Type …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs create-react-app tailwind-css

8
推荐指数
1
解决办法
1786
查看次数

通过ESLint版本在vscode上启动React应用失败

我有一个我无法解决的问题。我为所有项目在VSCode中使用ESLint。现在,我创建了一个新的react应用程序,但是当我运行它(npm start或yarn start)时,它会引发错误。

React应用使用ESLint 5.12.5,是我的较低版本。我尝试按照建议中的步骤进行操作,但...未解决。

谁能解决我的问题?

我试过npm uninstall -g eslint,npm uninstall eslint,npm i... bla..bla,打消了我的ESLint扩展在我VSCode,并重新创建应用程序的反应。但是错误尚未修复。
我检查了eslint -v,它表示为5.14.1,但是在错误通知中,vscode表示版本5.16.0在节点模块@@中。

当我尝试yarn start或时,这是完整的错误通知npm start:

> homework02@0.1.0 start E:\Extenal Code\Hoc JS\ReactJS-iViettech\homework02
> react-scripts start

There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

"eslint": "5.12.0"

Don't try …
Run Code Online (Sandbox Code Playgroud)

npm reactjs eslint visual-studio-code create-react-app

8
推荐指数
1
解决办法
1242
查看次数

反应挂钩-当嵌套属性在对象集合中更改时触发useEffect

页面显示对象列表。[{name:, age:}, ...] 第二页允许更新特定对象的名称。然后使用挂钩,如何实现,useEffect()以便仅在检测到名称更改时才更新首页上的列表?

const [objects, setObjects] = useState([]);

useEffect(()=> {
  getAllObjects()
},[getAllObjects, objects]);
Run Code Online (Sandbox Code Playgroud)

reactjs create-react-app react-hooks

8
推荐指数
2
解决办法
1695
查看次数

创建新的 TypeScript React 应用程序时不再支持别名导入

我通过此命令使用react@17.0.2和创建了一个新的 React-typescript 应用程序typescript@4.5.2:

npx create-react-app my-app --template typescript

然后我决定像之前多次那样定义别名路径。我tsconfig.paths.json在我的应用程序的根目录中创建了 。

{
  "compilerOptions": {
    "baseUrl": "./src",
    "paths": {
      "components/*": ["/components/*"],
      "routes/*": ["/routes/*"],
      "constants/*": ["/constants/*"]
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

然后我将extend属性添加到文件中tsconfig.json:

{
  "extends": "./tsconfig.paths.json",
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": [
    "src" …
Run Code Online (Sandbox Code Playgroud)

alias typescript reactjs create-react-app

8
推荐指数
1
解决办法
9475
查看次数