标签: create-react-app

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

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

reactjs semantic-ui create-react-app

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

antd设计选择占位符问题

我在我的React应用程序中使用antd设计.

这是我面临问题的代码片段:

<Select
     showSearch
     optionFilterProp = "children"
     placeholder = "Select Company"
     value = "{this.state.company}"
     name = "company"
     onSelect = "{this.handleCompanyChange}"
    >
Run Code Online (Sandbox Code Playgroud)

现在它显示正确的值,如果this.state.company不是null.但如果this.state.company是,empty或者null占位符没有出现.

如何解决此问题,以便占位符出现,如果value为null?

javascript reactjs redux create-react-app antd

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

在create-react-app中启用CORS

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

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

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

cors express create-react-app

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

ReactJS - SCRIPT1010:预期标识符 - 生产版本未在IE11上运行

我今天用create-react-app创建了一个新项目.生产版本在IE11上运行不正常,控制台显示以下错误:

SCRIPT1010: Expected identifier

它指向我的main.js中的行:

{var n=e&&e.__esModule?function(){return e.default}:function(){return e};

错误发生在上面的e.(默认)之后.我的包json很简单:

{
  "name": "sample-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.3.1",
    "react-dom": "^16.3.1",
    "react-scripts": "1.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}
Run Code Online (Sandbox Code Playgroud)

奇怪的是,我的开发服务器在IE11上完美运行所以问题只适用于生成版本.它也适用于Chrome.我需要填充吗?

polyfills internet-explorer-11 reactjs babeljs create-react-app

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

如何在启用isolatedModules = true选项的情况下创建包?

在一个文件中,我在以下行中导出包的所有类:

export {default as BoundList, IBoundListOption, TBoundListFilterFn} from './list/BoundList';
Run Code Online (Sandbox Code Playgroud)

生成表格错误:

TS1205: Cannot re-export a type when the '--isolatedModules' flag is provided.
Run Code Online (Sandbox Code Playgroud)

我现在如何导出课程?

在CRA2.1中发生此问题。不得不强制执行isolatedModules = true。我正在CRA2.1上制作组件库

typescript reactjs babeljs create-react-app

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

通过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
查看次数

在 React 上导入多个图像

我正在尝试构建一个反应应用程序,我必须使用多个图像,现在我必须导入我将使用的每个图像,例如:

import image from '/img/img1.png';

<img src={img} />
Run Code Online (Sandbox Code Playgroud)

或者还有其他方法吗???,

PS:我尝试过“require”,它也给出了一个错误:

<img src={windows.location.origin +'/img/img1.png'}/>
Run Code Online (Sandbox Code Playgroud)

没有输出

javascript jsx reactjs create-react-app

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

使用 create-react-app 和 Typescript 时如何在构建时加载 .md 文件?

我正在尝试加载要在构建时加载的 markdown 文件。我已经设置了一个使用 Typescript 并使用material_ui博客主题的create-react-app。

import ReactMarkdown from 'markdown-to-jsx';
import post1 from './blog-post.1.md';

export default function Main(props: MainProps) {
  const classes = useStyles();
  const { posts, title } = props;

  return (
    <Grid item xs={12} md={8}>
      <Typography variant="h6" gutterBottom>
        {title}
      </Typography>
      <Divider />
      {posts.map((post) => (
        <Markdown className={classes.markdown} key={post.substring(0, 40)}>
          {post}
        </Markdown>
      ))}
    </Grid>
  );
}
Run Code Online (Sandbox Code Playgroud)

如果帖子被指定为 markdown,它将正确呈现:const post = '# Sample blog post #### April 1, 2020 by [Olivier](/)'

所以问题是 .md 文件没有加载到变量中。

运行时npm start,html …

markdown typescript reactjs webpack create-react-app

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

使用 create React app 进行编译时,Typescript 不会出错

我已经使用设置了一个新项目npx create-react-app my-app --template typescript,并且没有更改任何配置设置。

如果我输入一些存在 TS 错误的代码,我的 IDE(VS Code)将显示该错误。但是,当我运行 start/build 时,我没有收到任何编译错误。

除此之外,npm run build在我们的 GitLab CI/CD 管道上运行时,确实会失败并出现错误。

我检查了我的 TS 版本,无论是在项目中还是我的全局模块所在的位置,都是相同的版本(4.1.3)。

正如我所说,我没有对 create React app 生成的内容进行任何更改,并且我尝试创建一个新项目并获得相同的结果。有人有什么想法吗?

编辑 - 要添加到这一点,如果我tsc在根目录运行,我会收到编译错误,但npm start我不会。

编辑 2 - 这是我在 package.json 中的脚本(与 CRA 提供给我们的内容相同)

"scripts": {
  "start": "react-scripts start",
  "build": "react-scripts build",
  "test": "react-scripts test",
  "eject": "react-scripts eject"
}
Run Code Online (Sandbox Code Playgroud)

typescript reactjs react-scripts create-react-app

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

绝对路径在 create-react-app 中不起作用

根据本文档,我在根目录中创建了一个 jsconfig.json 文件,以便能够在我的 React 应用程序(使用 create-react-app 设置)中使用绝对路径导入组件。不幸的是这不起作用。我尝试安装react-app-rewired 和react-app-rewire-alias 来尝试相同的操作,但没有成功。任何帮助,将不胜感激。

以下是我的 jsconfig.json 文件:

{
    "compilerOptions": {
      "baseUrl": "src"
    },
    "include": ["src"]
}
Run Code Online (Sandbox Code Playgroud)

以及引发错误的文件(src/Components/Pages/Login/LoginForm)

import React from 'react'
import './Login.css'

import ToggleButton from '@material-ui/lab/ToggleButton'
import ToggleButtonGroup from '@material-ui/lab/ToggleButtonGroup'

import IconButton from '@material-ui/core/IconButton'
import Button from '@material-ui/core/Button'
import Input from '@material-ui/core/Input'
import OutlinedInput from '@material-ui/core/OutlinedInput'
import InputLabel from '@material-ui/core/InputLabel'
import InputAdornment from '@material-ui/core/InputAdornment'
import FormControl from '@material-ui/core/FormControl'
import TextField from '@material-ui/core/TextField'

import {MdVisibility, MdVisibilityOff} from 'react-icons/md'
import { FormHelperText } from '@material-ui/core'

import …
Run Code Online (Sandbox Code Playgroud)

absolute-path reactjs create-react-app react-app-rewired

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