Build projects based on React-create-app and Nodejs

Source: Internet
Author: User

Create a project using React-create-app
    • Global installation NPM Install-g Create-react-app
    • Create Project Create-react-app + project name
Introducing the Sass processor writing style

Installation:

"Node-sass-chokidar" "^1.3.0","Npm-run-all" "^4.1.3",     

Package.json as follows:

"Scripts": {"Build-css":"Node-sass-chokidar Src/assets/sass-o Src/assets/css","Watch-css":"NPM run build-css && node-sass-chokidar src/assets/sass-o src/assets/css--watch--recursive","Start-js":"React-scripts Start", "Start":  npm-run-all-p Watch-css start-js" Build-js ": " react-scripts build ",  "Build":  Npm-run-all build-css Build-js "Test":  "react-scripts test--env=jsdom",  "Eject":           

Configuration method

Configure Proxy to Node layer
"Proxy": {    "/api" target"http://localhost:4222/"}}
Use
Node Layer configuration:
App.use ('/api/productsve ', productsve);
Router.get ('/getproducts ', function (req, res) {
var results = {
Id:1,
Title: ' Computer ',
price:5000,
}
Res.json (results);
});
Used in react:
Componentdidmount () {
Fetch ('/api/productsve/getproducts ')
. Then (res = {
Res.json ()
})
. Then (data = {
Console.log (data)
})
. catch (Err = {
Console.log (ERR)
})
}

Problems and Solutions

    • Packing times wrong: Import in body of module; Reorder to top Import/first
      • Solutions: 78722055

Build projects based on React-create-app and Nodejs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.