Exercise: React Intro
#
ObjectiveYour objective is to create your first react application with the create-react-app
tool, and investigate the starter files you are given.
This project repository will be used for all of the upcoming react exercises
#
Getting StartedThis is part 1 of TrueCoders' React Exercise Series.
We will create a new react repository that you work in for the duration of the series.
#
StepsReact Series Part 1 has multiple exercises.
- Exercise 1: Create the Project
- Exercise 2: Open Visual Studio Code
- Exercise 3: Start the React Development Server
- Exercise 4: Update the App
#
Exercise 1: Create the ProjectCreate a react project with create-react-app
- Navigate to your
repos/
folder (or other desired place where you keep your projects) - Create a new react project by running
npx create-react-app react-project
in your terminal
#
Exercise 2: Open Visual Studio CodeOpen the new react project in Visual Studio Code
- Open the app in VSCode.
- Take note of the templated file structure. Open some of the files to see what is there before you make any changes.
#
Exercise 3: Start the React Development ServerStart the development server to see the rendered output
- Start the
create-react-app
development server by runningnpm start
in your terminal - View the rendered output in the browser
- Running
npm start
should open your browser for you, but you can always access your development server by visiting http://localhost:3000 in your browser
- Running
Be sure to be at your
react-project/
folder in your terminal before runningnpm start
#
Exercise 4: Update the AppMake changes!
- Open the
src/App.js
file - Try to change the paragraph inner html from
Edit <code>src/App.js</code> and save to reload.
toReact is so cool!
- Keep your eyes on the rendered output in the browser. It changes automatically!
- Add the following elements to the content in the
App.js
file. No specific order or structure required. Just see the elements updated on the DOM with the development server running.- a heading 1 element
- another paragraph element
- an unordered list with 3 list items
We're going to be spending a lot of time in React, but for now, you've created a new React project with the create-react-app
tool, investigated the template source code, started the React development server, and made some initial changes!
#
Helpful LinksIf you feel stuck, or would like to see the finished code for this exercise to check your work, check out:
- React #1: React Intro Exercise Video on Vimeo
- React #1: React Intro Exercise Repo on Github