Giter VIP home page Giter VIP logo

studyreact's People

Contributors

cruxf avatar

Watchers

 avatar  avatar

Forkers

ht6677

studyreact's Issues

1.react脚手架构建运行时报错问题

操作过程

  • npm install -g create-react-app
  • create-react-app 项目名
  • npm 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:

“webpack”: “4.29.6”

Don’t try to install it manually: your package manager does it automatically.
However, a different version of webpack was detected higher up in the tree:

/Users/mac/Desktop/node_modules/webpack (version: 3.8.0)

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.

解决办法

在react-cli项目里面添加.env文件,文件中添加SKIP_PREFLIGHT_CHECK=true,在运行npm start。错误提示里又说这样可以解决目前问题,可能还会出现其他问题,暂时没遇到。

2.主文件调用组件报错

错误提示

is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.

错误原因

在主文件中调用组件,组件的名称不能用小写,只能使用大写

// error
import React from 'react';
import ReactDOM from 'react-dom';
mport routeDemo from './pages/routeDemo/reoute1/Home';
import * as serviceWorker from './serviceWorker';
ReactDOM.render(<routeDemo />, document.getElementById('root'));
serviceWorker.unregister();

// success
import React from 'react';
import ReactDOM from 'react-dom';
mport RouteDemo from './pages/routeDemo/reoute1/Home';
import * as serviceWorker from './serviceWorker';
ReactDOM.render(<RouteDemo />, document.getElementById('root'));
serviceWorker.unregister();

3.react使用antd警告

错误提示

Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Wave which is inside StrictMode. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://fb.me/react-strict-mode-find-node

警告原因:

是因为 react 中的严格模式: StrictMode

解决办法:

在index.js中挂载 App 的外面有这样一个标签<React.StrictMode>,只要把这个标签删除掉就可以了

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.