Coder Social home page Coder Social logo

create-react-app's Introduction

Create React App

Problem Statement

So far, through this React course, a basic framework of files has been provided in the labs. In order for React to work, a specific file structure is required. Having to set all that up every time can be a bit of a pain and is also prone to error. On top of this, copying and pasting old React projects means you may miss out on the most up-to-date React features.

Fortunately, the creators of React have also set up a handy tool for rapidly creating the barebones file structure we need for React apps. In this lesson, we will be discussing how to use the create-react-app node package to get our own projects off the ground.

Objectives

  • Ensure npm is updated to utilize newly included npx command
  • Review how to create a react app using create-react-app

Keeping Up To Date

Before we continue, it is recommended you run npm install -g npm. This will make sure you have the newest version of Node Package Manager. Once this is installed, you should now have access to npx. Instead of having to globally install a node package using npm, with npx, we can provide a node package name as an argument and use remote node packages as though they were installed.

Since you're grabbing the package remotely, you will be getting the most up to date version of it by default!

Creating A React App From Scratch

In your terminal, navigate to a location where you would like your React app directory to be located.

Decide on a name for your app. Once you've got one, run the following with your app's name in place of <your_app_name>:

npx create-react-app <your_app_name>

The create-react-app package sets up the basic file structure and executes an initial npm install.

Conclusion

That's it! Fast and easy. The app is ready to run with npm start, and will display some default content. The README.md file provided also has a very detailed breakdown of all the additional features that come with create-react-app.

One feature that is included: a service worker that allows the app to cache page data in a user's browser. The result? After a user visits your site once, if they do not have service, they can still go to your website and see content. The cache will display what the site looked like the last time the user was there!

While it is perfectly fine to set up your own React files, create-react-app is a handy solution to quickly get past any setup and get straight to designing your app. Since it is actively maintained by Facebook, you're also always getting a nicely polished, up-to-date base for your React applications!

create-react-app's People

Contributors

danielseehausen avatar lizbur10 avatar maxwellbenton avatar

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.