Published on 26th October, 2022 (11 months ago) ● Updated on 26th October, 2022
How to create a React Application
(3 minutes read)
Step 1: Create a React Application.
To begin, you'll need to create a new React application.
Create a directory to work in. You can use the terminal or your favorite editor and type in:
bash mkdir my-new-react-project && cd my-new-react-project
Create a package.json file by opening your favorite text editor (such as Atom) and typing "
npm init". This will ask for some information about how you want this project set up, including what version control system (GitHub, Bitbucket or GitLab) it should be associated with and other settings like naming conventions and license agreements. Once done filling out these fields a new file called package.json will be created in the directory where we ran npm init earlier on screen!
Step 2: Install Dependencies.
Now that you have a project, let's install the React and ReactDOM modules.
Install the react package:
npm install --save @react/addons-modules@latest
Install the react-dom package:
npm install --save @ react/dom
Step 3: Run the application.
To run your application, you have two options:
Running the application in the browser
npm startto run your app using Webpack's development server. This will allow you to see how it looks and feel before deploying it on Heroku or other hosting providers. The advantage of this method is that you can easily debug issues while they're happening rather than having them show up days later when it's too late! * To use this method, open a command prompt and navigate to where your webpack config file has been saved (usually at [YOUR WEBPACK PATH]/config) then type: `
npm run build`. This will generate all necessary files for production use including stylesheets, scripts etc.. If there are any errors during compilation then these should be listed here along with instructions on how fix them
React is designed so that it can be used in any context: client side, server side or native apps (e.g., Cordova).
In this tutorial, you learned how to create a React application with the help of Yarn and Webpack. We covered some basic concepts and then discussed ways to package your application for production by using yarn build and webpack.
HostPinnacle Kenya is the best and cheapest web hosting company in Kenya with world-class web hosting packages and affordable web design offers. Apart from that we offer free life-time SSL certificate, affordable domain registration in Kenya and free whois privacy. We have an award-winning support team available 24/7/365 to help you with your queries.