The hands-on project on Build Your First React Website is divided into following tasks:
Task 1: User interface orientation and finished product preview.
Task 2: React Overview.
Task 3: Create the starter website and start customising.
Task 4: Render the banner image with a functional component.
Task 5: Apply CSS to make the banner image responsive.
Task 6: Display a prototype photo with a class-based component.
Task 7: Make an album component and render all our photos.
Task 8: Dynamically generate the content for the album with JSON.
Task 9: Debugging React.
Front-End Web Development with React
(by The Hong Kong University of Science and Technology)
Part II of Front-end web development by Coursera & Hong Kong University of Science & Technology
About this course:
This course explores Javascript based front-end application development,
and in particular the React library (Currently Ver. 16.3).
This course will use JavaScript ES6 for developing React application.
You will;
Get an introduction to the use of Reactstrap for Bootstrap 4-based responsive UI design.
Be introduced to various aspects of React components.
Learn about React router and its use in developing single-page applications.
Learn about designing controlled forms.
Be introduced to the Flux architecture and Redux.
Explore various aspects of Redux and use it to develop React-Redux powered applications.
Learn to use Fetch for client-server communication and the use of REST API on the server side.
Get a quick tour through React animation support and testing rounds off the course.
You must have preferably completed the previous course in the specialization on Bootstrap 4, or have a working knowledge of Bootstrap 4 to be able to navigate this course.
Also, a good working knowledge of JavaScript, especially ES 5 is strongly recommended.
At the end of this course, you will:
Be familiar with client-side Javascript application development and the React library.
Be able to implement single page applications in React.
Be able to use various React features including components and forms.
Be able to implement a functional front-end web application using React.
Be able to use Reactstrap for designing responsive React applications.
Be able to use Redux to design the architecture for a React-Redux application.
Week - Syllabus
Week 1: Introduction to React - 10hrs
In this module we get a quick introduction to front-end JavaScript frameworks and libraries, followed by an introduction to React. We will also learn about React components and JSX.
Week 2
React Router and Single Page Applications
In this week, you will learn about various component types. You will
learn about React router and its use in designing single page
applications. You will also learn about single page applications and use
React Router to design single page applications.
Week 3
React Forms, Flow Architecture and Introduction to Redux
In this module you will be introduced to uncontrolled and controlled
forms and briefly examine form validation in React applications. You
will get an overview of the Flux architecture and introduced to Redux as
a way of realizing the flux architecture.
Week 4
More Redux and Client-Server Communication
In this module you will explore Redux further including Redux action,
combining reducers, and Redux thunk, client-server communication using
Fetch and the REST API. You will get a brief introduction to animation
in React. You will also learn about testing, building and deploying
React applications.
This course explores Javascript based front-end application development,
and in particular the React library (Currently Ver. 16.3).
This course will use JavaScript ES6 for developing React application.
You will also get an introduction to the use of Reactstrap for Bootstrap 4-based responsive UI design.
You will be introduced to various aspects of React components.
You will learn about React router and its use in developing single-page applications.
You will also learn about designing controlled forms.
You will be introduced to the Flux architecture and Redux.
You will explore various aspects of Redux and use it to develop React-Redux powered applications.
You will then learn to use Fetch for client-server communication and the use of REST API on the server side.
A quick tour through React animation support and testing rounds off the course.
You must have preferably completed the previous course in the specialization on Bootstrap 4, or have a working knowledge of Bootstrap 4 to be able to navigate this course.
Also, a good working knowledge of JavaScript, especially ES 5 is strongly recommended.
At the end of this course, you will:
Be familiar with client-side Javascript application development and the React library
Be able to implement single page applications in React
Be able to use various React features including components and forms
Be able to implement a functional front-end web application using React
Be able to use Reactstrap for designing responsive React applications
Be able to use Redux to design the architecture for a React-Redux application.
Module 1: Full Stack Web Development: The Big Picture: Objectives and Outcomes
This lesson gives you a big picture view of the Full Stack Web
Development. The lecture gives you an overview of full stack web
development.
At the end of this lesson (#1), you will be able to:
Understand what is meant by full stack in the context of web development.
Distinguish between front-end, back-end and full stack web development
Understand the position of this course in the context of this specialization
WEEK # 1
Introduction to React
In this module we get a quick introduction to front-end JavaScript
frameworks and libraries, followed by an introduction to React. We will
also learn about React components and JSX.
Learning Objectives
Express the general characteristics of JavaScript frameworks and libraries
Create a new project using React
Create React components within your React application
Express what is meant by full-stack web development
Welcome to Front-End Web Development with React 10m
Module 3: Setting up Your Development Environment: Git and Node: Objectives and Outcomes
At the end of this lesson, you should have set up Git and Node.js on
your computer. You can skip this lesson if you have already completed
this as part of an earlier course in the specialization. At the end of
this lesson, you will be able to:
- Set up a Git repository and perform basic Git operations
- Set up and use online Git repositories
- Use Node-based modules to perform basic operations.
Setting up your Development Environment
Software Requirements
1. Text editor of your choice: Any text editor that you are already
familiar with can be used for editing the project files. I will be
using Visual Studio Code () as the
editor of choice in this specialization. You may also consider other
editors such as Brackets (), Sublime Text
(, or Atom ().
2. Browser of your choice: You may use your preferred browser. I
will be using Chrome as the browser in all the exercises. All the
exercises and assignments in this course have been tested using
Chrome v. 46. Please note that not all browsers may support all the
HTML5 features to the same extent. You might encounter problems when
using other browsers. I strongly urge you to use the latest Chrome
browser for the exercises and assignments in this course so that any
problems are minimized.
3. Command line shell: Familiarity with the command-line shell will
be essential for the exercises. In Windows a cmd window or power
shell with admin privileges would be needed. On a Mac or in Linux, a
terminal window can be used. Please get familiar with the \"sudo\"
command in OS X and Linux.
4. Files required for the exercises: We will provide additional
starter files for the exercises wherever needed. Links to download
the files will be provided inline in the exercise instructions
that follow each exercise video. Please download the files provided
there, if any, before beginning the exercise. The links are also
available through the Additional Resources of the specific
lesson.
Note: Please remember to retain the folders and all the files that you
create in the exercises. Further exercises will build upon the files
that you create in the preceding exercises. DO NOT DELETE the files at
the end of the exercises, unless otherwise instructed. You may wish to
set up your exercise folder as a Git repository and commit the files to
the repository at the end of each exercise.
Exercise (Video): Setting up Git
Exercise (Instructions): Setting up Git
Objectives and Outcomes
In this exercise you will learn to install Git on your computer. Git is
required for using all the remaining Node.js and Node based tools that
we encounter in the rest of the course. At the end of this exercise, you
would be able to:
- Install Git on your computer
- Ensure that Git can be used from the command-line or command-prompt
on your computer
- Set up some of the basic global configuration for Git
Downloading and Installing Git
- To install Git on your computer, go to
to download the Git installer for
your specific computing platform.
- Then, follow the installation steps as you install Git using the
installer.
- You can find more details about installing Git at
.
This document lists several ways of installing Git on various
platforms.
- Installing some of the GUI tools like GitHub Desktop will also
install Git on your computer.
- On a Mac, setting up XCode command-line tools also will set up Git
on your computer.
- You can choose any of the methods that is most convenient for you.
Some Global Configuration for Git
- Open a cmd window or terminal on your computer.
- Check to make sure that Git is installed and available on the
command line, by typing the following at the command prompt:
```
$ git --version
```
To configure your user name to be used by Git, type the following at the prompt:
To configure your email to be used by Git, type the following at the prompt:
```
$ git config ‐‐global user.email <your email address>
```
- You can check your default Git global configuration, you can type
the following at the prompt:
Exercise (Video): Basic Git Commands
```
$ git config --list
```
Conclusions
At the end of this exercise you should have Git available on the
command-line of your computer.
Exercise (Instructions): Basic Git Commands
Objectives and Outcomes
In this exercise you will get familiar with some basic Git commands. At
the end of this exercise, you will be able to:
- Set up a folder as a Git repository
- Perform basic Git operations on your Git repository
Basic Git Commands
At a convenient location on your computer, create a folder named git-test.
Open this git-test folder in your favorite editor.
Add a file named index.html to this folder, and add the following HTML code to this file:
```
<!DOCTYPE html>
<html>
<head></head>
<body>
<h1>This is a Header</h1>
</body>
</html>
```
Initializing the folder as a Git repository
- Go to the git-test folder in your cmd window/terminal and type the
following at the prompt to initialize the folder as a Git
repository:
```
$ git init
```
Checking your Git repository status
- Type the following at the prompt to check your Git repository\'s
status:
```
$ git status
```
Adding files to the staging area
- To add files to the staging area of your Git repository, type:
```
$ git add .
```
Commiting to the Git repository
- To commit the current staging area to your Git repository, type:
```
$ git commit -m "first commit"
```
Checking the log of Git commits
- To check the log of the commits to your Git repository, type
```
$ git log --oneline
```
- Now, modify the index.html file as follows:
```
<!DOCTYPE html>
<html>
<head></head>
<body>
<h1>This is a Header</h1>
<p>This is a paragraph</p>
</body>
</html>
```
- Add a sub-folder named templates to your git-test folder,
and then add a file named test.html to the templates folder. Then
set the contents of this file to be the same as the index.html
file above.
- Then check the status and add all the files to the staging area.
- Then do the second commit to your repository
- Now, modify the index.html file as follows:
```
<html>
<head></head>
<body>
<h1>This is a Header</h1>
<p>This is a paragraph</p>
<p>This is a second paragraph</p>
</body>
</html>
```
- Now add the modified index.html file to the staging area and then do
a third commit.
Checking out a file from an earlier commit
- To check out the index.html from the second commit, find the number
of the second commit using the git log, and then type the following
at the prompt:
```
$ git checkout <second commit's number> index.html
```
Resetting the Git repository
- To discard the effect of the previous operation and restore
index.html to its state at the end of the third commit, type:
```
$ git reset HEAD index.html
```
- Then type the following at the prompt:
```
$ git checkout -- index.html
```
- You can also use git reset to reset the staging area to the last
commit without disturbing the working directory.
Conclusions
At the end of this exercise, you should have learnt some basic Git
commands. Experiment with these commands until you fully understand how
to use Git.
Exercise (Video): Online Git Repositories
Exercise (Instructions): Online Git Repositories
Objectives and Outcomes
In this exercise you will learn about how to set up and use an online
Git repository and synchronize your local Git repository with your
online repository. At the end of this exercise, you will be able to:
- Set up the online repository as a remote repository for your local
Git repository
- Push your commits to the online repository
- Clone an online Git repository to your computer
Setting up an Online Git repository
- Sign up for an account either at Bitbucket
([https://bitbucket.org](https://bitbucket.org/)) or GitHub
([https://github.com](https://github.com/)).
- Then set up an online Git repository named git-test. Note the
URL of your online Git repository. Note that private repositories on
GitHub requires a paid account, and is not available for free
accounts.
Set the local Git repository to set its remote origin
- At the prompt, type the following to set up your local repository to
link to your online Git repository:
```
$ git remote add origin <repository URL>
```
Pushing your commits to the online repository
- At the prompt, type the following to push the commits to the online
repository:
```
$ git push -u origin master
```
Cloning an online repository
- To clone an online repository to your computer, type the following
at the prompt:
```
$ git clone <repository URL>
```
Conclusions
In this exercise you have learnt to set up an online Git repository,
synchronize your local repository with the remote repository, and clone
an online repository.
Module 4: Node.js and NPM
Exercise (Video): Setting up Node.js and NPM
Exercise (Instructions): Setting up Node.js and NPM
Note: Make sure you have installed Git on your machine before you
install Node.js. Please complete the previous Git installation exercise
before proceeding with this exercise.
Objectives and Outcomes
In this exercise, you will learn to set up the Node.js environment, a
popular Javascript based server framework, and node package manager
(NPM) on your machine. To learn more about NodeJS, you can visit
[https://nodejs.org](https://nodejs.org/). For this course, you just
need to install Node.js on your machine and make use of it for running
some front-end tools. You will learn more about the server-side support
using Node.js in a subsequent course. At the end of this exercise, you
will be able to:
- Complete the set up of Node.js and NPM on your machine
- Verify that the installation was successful and your machine is
ready for using Node.js and NPM.
Installing Node
- To install Node on your machine, go to
[https://nodejs.org](https://nodejs.org/) and click on the Download
button. Depending on your computer\'s platform (Windows, MacOS or
Linux), the appropriate installation package is downloaded.
- As an example, on a Mac, you will see the following web page. Click
on the Download button. Follow along the instructions to install
Node on your machine. (Note: Now Node gives you the option of
installing a mature and dependable LTS version and a more newer
stable version. You should to install the LTS version. I will use
this version in the course.)
Note: On Windows machines, you may need to configure your PATH
environmental variable in case you forgot to turn on the add to PATH
during the installation steps.
Verifying the Node Installation
- Open a terminal window on your machine. If you are using a Windows
machine, open a cmd window or PowerShell window with admin
privileges.
- To ensure that your NodeJS setup is working correctly, type the
following at the command prompt to check for the version of Node
and NPM
```
$ node -v
$ npm -v
```
Conclusions
At the end of this exercise, your machine is now ready with the Node
installed for further development. We will examine web development tools
next.
Exercise (Video): Basics of Node.js and NPM
Exercise (Instructions): Basics of Node.js and NPM
Objectives and Outcomes
In this exercise you will learn the basics of Node and NPM. At the end
of this exercise, you will be able to:
- Set up package.json file in the project folder for configuring your
Node and NPM for this project
- Install a NPM module and make use of it within your project
Initializing package.json
- At the command prompt in your git-test folder, type
> npm init
- Follow along the prompts and answer the questions as follows: accept
the default values for most of the entries, except set the entry
point to index.html
- This should create a package.json file in your git-test
folder.
Installing an NPM Module
- Install an NPM module, lite-server, that allows you to run a Node.js
based development web server and serve up your project files. To do
this, type the following at the prompt:
> npm install lite-server --save-dev
- You can check out more documentation on lite-server
[here](https://github.com/johnpapa/lite-server).
- Next, open package.json in your editor and modify it as shown below.
Note the addition of two lines, line 7 and line 9.
```
{
"name": "git-test",
"version": "1.0.0",
"description": "This is the Git and Node basic learning project",
"main": "index.html",
"scripts": {
"start": "npm run lite",
"test": "echo "Error: no test specified" && exit 1",
"lite": "lite-server"
},
"repository": {
"type": "git",
"url": "git+[https://[email protected]/jogesh_k_muppala/git-test.git]{.underline}"
},
"author": "",
"license": "ISC",
"homepage": "[https://bitbucket.org/jogesh_k_muppala/git-test#readme]{.underline}",
"devDependencies": {
"lite-server": "^2.2.2"
}
}
```
- Next, start the development server by typing the following at the
prompt:
```
$ npm start
```
- This should open your index.html page in your default browser.
- If you now open the index.html page in an editor and make changes
and save, the browser should immediately refresh to reflect the
changes.
Setting up .gitignore
- Next, create a file in your project directory named .gitignore
(Note: the name starts with a period)Then, add the following to
the .gitignore file
```
$ node_modules
```
- Then do a git commit and push the changes to the online repository.
You will note that the node_modules folder will not be added to the
commit, and will not be uploaded to the repository.
Conclusions
In this exercise you learnt to set up package.json, install a npm
package and start a development server.
Setting up your Development Environment: Git and Node: Additional Resources
Module 4: Introduction to React: Objectives and Outcomes
In this lesson you will be given a quick overview of JavaScript
frameworks and libraries and then introduced to React in particular. We
will learn some basics of React and how to configure a React application
using the create-react-app the command line tool. At the end of this
lesson, you will be able to:
- Get a basic overview of JavaScript frameworks and libraries
- Understand the architecture of an React application
- Scaffold out a starter React application using create-react-app,
the command line tool
Front-end JavaScript Frameworks and Libraries Overview
Introduction to React
Exercise (Video): Getting Started with React
Exercise (Instructions): Getting Started with React
Objectives and Outcomes
In this first React exercise, you will first install create-react-app,
the command line tool for scaffolding React applications. You will then
use the tool to scaffold out a basic React application. We will
thereafter develop this application into a full-fledged React
application in the process of doing the exercises in this course. At the
end of this exercise you will be able to:
- Install create-react-app
- Scaffold out a basic React application
Installing Yarn
- Yarn is another package manager like NPM, but is better suited and
faster to work with for React applications. So let us install yarn
and use it for building our React applications.
- To install Yarn, you can find the instructions for your specific
platform at .
- If you choose not to install Yarn, you can continue to use npm in
place of yarn without any problem.
Installing create-react-app
From the React documentation we learn that the create-react-app CLI
makes it easy to create an application that already works, right out of
the box. It already follows the best practices suggested by the React
community!
- To install create-react-app globally, type the following at the
prompt:
> yarn global add
Use sudo on a Mac and Linux. Alternately you can use npm, by typing
\"npm install -g [email protected]\".
- This will make the command line tool for creating React
applications. To learn more about the various commands that this CLI
provides, type at the prompt:
```
$ create-react-app --help
```
Generating and Serving a React Project using create-react-app
- At a convenient location on your computer, create a folder named
React and move into that folder.
- Then type the following at the prompt to create a new React
application named confusion:
```
$ create-react-app confusion
```
- This should create a new folder named confusion within your
React folder and create the React application in that folder.
- Move to the confusion folder and type the following at the prompt:
```
$ yarn start
```
- This will compile the project and then open a tab in your default
browser at the address <Your Computer\'s Name>:3000.
- You can initialize your project to be a Git repository by typing the
following commands at the prompt:
```
$ git init
$ git add .
$ git commit -m "Initial Setup"
```
- Thereafter you can set up an online Git repository and synchronize
your project to the online repository. Make sure that the online Git
repository is a private repository.
Conclusions
In this exercise you installed the create-react-app CLI tool and created
a basic React project and served up the compiled project to your
browser.
React App Overview
Introduction to JSX
Setting up your Development Environment
Software Requirements
1. Text editor of your choice: Any text editor that you are already
familiar with can be used for editing the project files. I will be
using Visual Studio Code () as the
editor of choice in this specialization. You may also consider other
editors such as Brackets (), Sublime Text
(, or Atom ().
2. Browser of your choice: You may use your preferred browser. I
will be using Chrome as the browser in all the exercises. All the
exercises and assignments in this course have been tested using
Chrome v. 46. Please note that not all browsers may support all the
HTML5 features to the same extent. You might encounter problems when
using other browsers. I strongly urge you to use the latest Chrome
browser for the exercises and assignments in this course so that any
problems are minimized.
3. Command line shell: Familiarity with the command-line shell will
be essential for the exercises. In Windows a cmd window or power
shell with admin privileges would be needed. On a Mac or in Linux, a
terminal window can be used. Please get familiar with the \"sudo\"
command in OS X and Linux.
4. Files required for the exercises: We will provide additional
starter files for the exercises wherever needed. Links to download
the files will be provided inline in the exercise instructions
that follow each exercise video. Please download the files provided
there, if any, before beginning the exercise. The links are also
available through the Additional Resources of the specific
lesson.
WEEK # 2
React Router and Single Page Applications
In this week, you will learn about various component types. You will
learn about React router and its use in designing single page
applications. You will also learn about single page applications and use
React Router to design single page applications.
[Presentational and Container Components](https://www.coursera.org/lecture/front-end-react/presentational-and-container-components-TZMPB) 6m
WEEK # 3
React Forms, Flow Architecture and Introduction to Redux
In this module you will be introduced to uncontrolled and controlled
forms and briefly examine form validation in React applications. You
will get an overview of the Flux architecture and introduced to Redux as
a way of realizing the flux architecture.
In this module you will explore Redux further including Redux action,
combining reducers, and Redux thunk, client-server communication using
Fetch and the REST API. You will get a brief introduction to animation
in React. You will also learn about testing, building and deploying
React applications.
Networking Essentials 17m
Brief Representational State Transfer (REST) 16m
Exercise (Video): Setting up a Server using json-server 6m
Promises 10m
Fetch 20m
Exercise (Video): Fetch from Server 33m
Exercise (Video): Fetch Handling Errors 15m
Exercise (Video): Fetch Post Comment 18m
React Animations 13m
Exercise (Video): React Animations 9m
Exercise (Video): React Animation Components 9m
Assignment 4: Redux, Client-Server Communication and Fetch 4m
Introduction to Webpack 7m
Exercise (Video): Building and Deploying the React Application 11m
26 readings
Redux Actions: Objectives and Outcomes 10m
Exercise (Instructions): Combining Reducers 10m
Exercise (Instructions): Redux Actions 10m
Redux Actions: Additional Resources 10m
Redux Thunk: Objectives and Outcomes 10m
Exercise (Instructions): Redux Thunk 10m
Exercise (Instructions): React-Redux-Form Revisited 10m
Redux Thunk: Additional Resources 10m
Client-Server Communication: Objectives and Outcomes 10m
Exercise (Instructions): Setting up a Server using json-server 10m
Client-Server Communication: Additional Resources 10m
Fetch: Objectives and Outcomes 10m
Exercise (Instructions): Fetch from Server 10m
Exercise (Instructions): Fetch Handling Errors 10m
Exercise (Instructions): Fetch Post Comment 10m
Fetch: Additional Resources 10m
React Animations: Objectives and Outcomes 10m
Exercise (Instructions): React Animations 10m
Exercise (Instructions): React Animation Components 10m
React Animations: Additional Resources 10m
Assignment 4: Redux, Client-Server Communication and Fetch: Additional
Resources 10m
Building and Deployment: Objectives and Outcomes 10m
Exercise (Instructions): Building and Deploying the React Application
10m
Building and Deployment: Additional Resources 10m
Project Implementation: Objectives and Outcomes 10m
Final Report Template 10m
# Exercise (Instructions): Setting up Git
Objectives and Outcomes
In this exercise you will learn to install Git on your computer. Git is
required for using all the remaining Node.js and Node based tools that
we encounter in the rest of the course. At the end of this exercise, you
would be able to:
- Install Git on your computer
- Ensure that Git can be used from the command-line or command-prompt
on your computer
- Set up some of the basic global configuration for Git
Downloading and Installing Git
- To install Git on your computer, go to
to download the Git installer for
your specific computing platform.
- Then, follow the installation steps as you install Git using the
installer.
- You can find more details about installing Git at
.
This document lists several ways of installing Git on various
platforms.
- Installing some of the GUI tools like GitHub Desktop will also
install Git on your computer.
- On a Mac, setting up XCode command-line tools also will set up Git
on your computer.
- You can choose any of the methods that is most convenient for you.
Some Global Configuration for Git
- Open a cmd window or terminal on your computer.
- Check to make sure that Git is installed and available on the
command line, by typing the following at the command prompt:
```
$ git --version
```
- To configure your user name to be used by Git, type the following at
the prompt:
```
$ git config --global user.name "Your Name"
```
- To configure your email to be used by Git, type the following at the
prompt:
```
$ git config --global user.email <your email address>
```
- You can check your default Git global configuration, you can type
the following at the prompt:
```
$ git config --list
```
Conclusions
At the end of this exercise you should have Git available on the
command-line of your computer.
Exercise (Video): Basic Git Commands
Exercise (Instructions): Basic Git Commands
Objectives and Outcomes
In this exercise you will get familiar with some basic Git commands. At
the end of this exercise you will be able to:
- Set up a folder as a Git repository
- Perform basic Git operations on your Git repository
Basic Git Commands
- At a convenient location on your computer, create a folder named
git-test.
- Open this git-test folder in your favorite editor.
- Add a file named index.html to this folder, and add the following
HTML code to this file:
```
<!DOCTYPE html>
<html>
<head></head>
<body>
<h1>This is a Header</h1>
</body>
</html>
```
Initializing the folder as a Git repository
- Go to the git-test folder in your cmd window/terminal and type the
following at the prompt to initialize the folder as a Git
repository:
```
$ git init
```
Checking your Git repository status
- Type the following at the prompt to check your Git repository\'s
status:
```
$ git status
```
Adding files to the staging area
- To add files to the staging area of your Git repository, type:
```
$ git add .
```
Commiting to the Git repository
- To commit the current staging area to your Git repository, type:
```
$ git commit -m "first commit"
```
Checking the log of Git commits
- To check the log of the commits to your Git repository, type
```
$ git log --oneline
```
- Now, modify the index.html file as follows:
```
This is a Header
This is a paragraph
```
Add a sub-folder named templates to your git-test folder,
and then add a file named test.html to the templates folder. Then
set the contents of this file to be the same as the index.html
file above.
Then check the status and add all the files to the staging area.
Then do the second commit to your repository
Now, modify the index.html file as follows:
```
This is a Header
This is a paragraph
This is a second paragraph
```
- Now add the modified index.html file to the staging area and then do
a third commit.
Checking out a file from an earlier commit
- To check out the index.html from the second commit, find the number
of the second commit using the git log, and then type the following
at the prompt:
```
$ git checkout <second commit's number> index.html
```
Resetting the Git repository
To discard the effect of the previous operation and restore
index.html to its state at the end of the third commit, type:
```
$ git reset HEAD index.html
```
Then type the following at the prompt:
```
$ git checkout -- index.html
```
You can also use git reset to reset the staging area to the last
commit without disturbing the working directory.
Conclusions
At the end of this exercise you should have learnt some basic Git
commands. Experiment with these commands until you fully understand how
to use Git.
Online Git Repositories
Exercise (Instructions): Online Git Repositories
Objectives and Outcomes
In this exercise you will learn about how to set up and use an online
Git repository and synchronize your local Git repository with your
online repository. At the end of this exercise, you will be able to:
- Set up the online repository as a remote repository for your local
Git repository
- Push your commits to the online repository
- Clone an online Git repository to your computer
Setting up an Online Git repository
- Sign up for an account either at Bitbucket
([https://bitbucket.org](https://bitbucket.org/)) or GitHub
([https://github.com](https://github.com/)).
- Then set up an online Git repository named git-test. Note the
URL of your online Git repository. Note that private repositories on
GitHub requires a paid account, and is not available for free
accounts.
Set the local Git repository to set its remote origin
- At the prompt, type the following to set up your local repository to
link to your online Git repository:
```
$ git remote add origin <repository URL>
```
Pushing your commits to the online repository
- At the prompt, type the following to push the commits to the online
repository:
```
$ git push -u origin master
```
Cloning an online repository
- To clone an online repository to your computer, type the following
at the prompt:
```
$ git clone <repository URL>
```
Conclusions
In this exercise you have learnt to set up an online Git repository,
synchronize your local repository with the remote repository, and clone
an online repository.
Node.js and NPM
JavaScript which was designed as a scripting language for the
browser, has seen deployment far beyond the browser.
Node.js has played a significant role in this shift of JavaScript from
the browser to the desktop.
Let\'s now learn a little bit about what node.js is and what role does
NPM, the Node Package Manager, play in the context of node.js.
Node.js as I mentioned earlier, allows us to bring the power of
JavaScript to the desktop.
Node.js is based on the JavaScript runtime engine that has been built
for the Chrome browser.
The Chrome V8 JavaScript engine has been ported from the browser to run
on the desktop and support the execution of JavaScript programs on the
desktop.
Node.js is built around an event driven non blocking I/O model which
makes it very efficient to run JavaScript programs on the desktop and
synchronous Javascript on the desktop.
Now, this is where node finds its true pouch.
Right now, we will examine Node.js In the context of its use as a
JavaScript runtime.
We\'ll look at the server-side application of Node.js In detail in the
last course of this specialization.
This is the typical architecture of Node.js.
In this, the Chrome V8 engine is at the bottom layer together with libuv
forms, the layer that interacts with the underlying computer system to
support the execution of JavaScript programs.
On top of it, we have Node Bindings which are also implemented in C++.
At the top layer, you have the Node.js and standard library which are
all implemented in JavaScript, and this is what enables us to write
JavaScript programs and run them on the desktop.
Naturally, the ability to run JavaScript programs on the desktop
energize the web development community to explore using JavaScript to
develop a significant number of web development tools.
Tools such as Bower, Grunt, Gulp, Yeoman, and many others.
We will explore some of these in the later part of this course and in
subsequent courses.
The last course in the specialization, as I mentioned, looks at the use
of Node.js on the server side.
How we can develop Web server, Business logic, all implemented in
JavaScript on the server site.
Together with Node, you often hear people talking about the Node Package
Manager or NPM.
When you install Node on your computer, NPM automatically gets
installed.
The Node Package Manager is the manager for the node ecosystem
that manages all the node modules and packages that have been made
publicly available by many different users.
A typical node package consist of JavaScript files together with a
file called package.json which is the manifest file for this node
module.
We will look at how we can use the package.json file in more detail in
the subsequent exercises.
Exercise (Video): Setting up Node.js and NPM
Exercise (Instructions): Setting up Node.js and NPM
Note: Make sure you have installed Git on your machine before you
install Node.js. Please complete the previous Git installation exercise
before proceeding with this exercise.
Objectives and Outcomes
In this exercise, you will learn to set up the Node.js environment, a
popular Javascript based server framework, and node package manager
(NPM) on your machine. To learn more about NodeJS, you can visit
[https://nodejs.org](https://nodejs.org/). For this course, you just
need to install Node.js on your machine and make use of it for running
some front-end tools. You will learn more about the server-side support
using Node.js in a subsequent course. At the end of this exercise, you
will be able to:
- Complete the set up of Node.js and NPM on your machine
- Verify that the installation was successful and your machine is
ready for using Node.js and NPM.
Installing Node
- To install Node on your machine, go to
[https://nodejs.org](https://nodejs.org/) and click on the Download
button. Depending on your computer\'s platform (Windows, MacOS or
Linux), the appropriate installation package is downloaded.
- As an example, on a Mac, you will see the following web page. Click
on the Download button. Follow along the instructions to install
Node on your machine. (Note: Now Node gives you the option of
installing a mature and dependable LTS version and a more newer
stable version. You should to install the LTS version. I will use
this version in the course.)
Note: On Windows machines, you may need to configure your PATH
environmental variable in case you forgot to turn on the add to PATH
during the installation steps.
Verifying the Node Installation
- Open a terminal window on your machine. If you are using a Windows
machine, open a cmd window or PowerShell window with admin
privileges.
- To ensure that your NodeJS setup is working correctly, type the
following at the command prompt to check for the version of Node
and NPM
```
$ npm -v
```
Conclusions
At the end of this exercise, your machine is now ready with the Node
installed for further development. We will examine web development tools
next.
Exercise (Instructions): Basics of Node.js and NPM
Objectives and Outcomes
In this exercise you will learn the basics of Node and NPM. At the end
of this exercise, you will be able to:
- Set up package.json file in the project folder for configuring your
Node and NPM for this project
- Install a NPM module and make use of it within your project
Initializing package.json
- At the command prompt in your git-test folder, type
```
$ npm init
```
- Follow along the prompts and answer the questions as follows: accept
the default values for most of the entries, except set the entry
point to index.html
- This should create a package.json file in your git-test
folder.
Installing an NPM Module
- Install an NPM module, lite-server, that allows you to run a Node.js
based development web server and serve up your project files. To do
this, type the following at the prompt:
```
$ npm install lite-server --save-dev
```
- You can check out more documentation on lite-server
[here](https://github.com/johnpapa/lite-server).
- Next, open package.json in your editor and modify it as shown below.
Note the addition of two lines, line 7 and line 9.
```
"start": "npm run lite",
"test": "echo "Error: no test specified" && exit 1",
"lite": "lite-server"
},
"repository": {
"type": "git",
"url": "git+[https://[email protected]/jogesh_k_muppala/git-test.git]{.underline}"
},
"author": "",
"license": "ISC",
"homepage": "[https://bitbucket.org/jogesh_k_muppala/git-test#readme]{.underline}",
"devDependencies": {
"lite-server": "^2.2.2"
}
}
```
- Next, start the development server by typing the following at the
prompt:
```
$ npm start
```
- This should open your index.html page in your default browser.
- If you now open the index.html page in an editor and make changes
and save, the browser should immediately refresh to reflect the
changes.
Setting up .gitignore
- Next, create a file in your project directory named .gitignore
(Note: the name starts with a period)Then, add the following to
the .gitignore file
```
$ node_modules
```
- Then do a git commit and push the changes to the online repository.
You will note that the node_modules folder will not be added to the
commit, and will not be uploaded to the repository.
Conclusions
In this exercise you learnt to set up package.json, install a npm
package and start a development server.
Setting up your Development Environment: Git and Node: Additional Resources
PDFs of Presentations
Git.pdf
PDF File
Git-Exercises.pdf
PDF File
NodeJS.pdf
PDF File
Exercises-Node-NPM.pdf
PDF File
In this lesson you will be given a quick overview of JavaScript
frameworks and libraries and then introduced to React in particular. We
will learn some basics of React and how to configure a React application
using the create-react-app the command line tool. At the end of this
lesson, you will be able to:
- Get a basic overview of JavaScript frameworks and libraries
- Understand the architecture of an React application
- Scaffold out a starter React application using create-react-app,
the command line tool
Front-end JavaScript Frameworks and Libraries Overview
Introduction to React
We ended the previous lecture with a question, is React a library or is
it a framework and what exactly is React?
Let\'s examine these questions in a bit more detail in this lecture.
Let\'s start out with the very first question.
What exactly is React and how is it different from the other frameworks
or libraries that we have mentioned in the previous lecture?
When you visit React website, you see it clearly specified right on the
front page that React is a JavaScript library for building user
interfaces.
Now again, depending on who you ask some people tend to call React a
library and others tend to call it a framework.
Now, let\'s not bother ourselves too much in splitting our hairs over
whether it is a framework, or a library but let\'s concentrate more on
what it actually helps us accomplish.
It is more important for us to understand that rather than worrying
about whether it is a framework or a library.
The React approach to implementing them applications is what we are
after in this course.
So, React also states that it uses a declarative approach.
Now that leaves you in a confused state because we saw that frameworks
generally tend to use the declarative approach.
But in React, the declarative approach used by React as specified on its
website says that, it makes it easy to create interactive UIs with
simple views for each state within your application.
And also React takes care of automatically updating the UI and then
rendering any changes to their specific components as required on your
page.
You just heard me mentioning the term Component.
React Indeed is a component based approach.
In a Component based approach, we encapsulate behaviors into small units
called Components.
We will examine Components in more detail in the next lesson.
There it will become more clear to you how, and why a component based
approach is useful for implementing our Web applications in React.
Furthermore, React makes no assumptions about the entire technology
stack that you\'re going to use for implementing your Web applications.
React plays well with any technology stack that you can use behind the
seats.
React itself concentrates only on the user interface side of the
story, and that leaves it up to the application designer to decide how
they want to implement the architecture and how they want your
application to interact with the back-end server.
So, as we go through this course, we will examine one approach that we
use for implementing the entire technology stack which includes the Flux
architecture approach, and in specifically the use of Redux for
implementing a state based storage for our Web application and also the
use of Fetch for interacting with our back-end server.
Again, I\'ve mentioned a few terms like Flux, Redux, and Fetch.
We will examine these towards the second half of this course.
It\'s obviously useful to examine the history behind the React
approach.
So, to understand where React originated, and how it came about to the
state it is today.
React was first designed by Jordan Walke who was part of the Facebook
team.
It was first deployed for Facebook\'s news feed around 2011.
Subsequently in 2013, React was open sourced at this JS conference.
React took off as an approach for implementing Web applications from
then onwards.
React is designed for speed, speed of implementing the application,
simplicity, and scalability.
The three essence of React, and why it has become so popular in the real
value.
As we examine React more in this course, you\'ll become more and more
familiar with why this approach is very suited for implementing Web
applications.
As you enter the React world you will be bombarded with a lot of
vocabulary that is used in the React world.
You will hear people talking about One-way data flow especially in the
context of the Flux Architecture.
You will often hear people mentioning about JSX, we will examine JSX in
the very next lecture and understand what role it plays in developing a
React application.
We\'ll hear about Components which we will examine in the next lesson
and also in the second module of this course in more detail and we\'ll
here about the state and how a React Component interacts with the state
of your application and the way you store the state of your
application, or do you store the state in a specific component.
We\'ll also hear about Props, a way of passing data between the various
components.
Also, we\'ll hear about Virtual Dom, and how is it different from Real
DOM.
Why React manipulate the Virtual DOM, and how the Virtual DOM eventually
gets incorporated, or rendered onto the Real DOM.
And Element, the React Element, which is the smallest unit of building
up a React application.
A component being a collection of React elements.
Then we hear about the Flux and Redux architectures in a bit more
detail.
Again, as we go along this course we will examine these concepts and
these terminology in more detail.
Again, don\'t get overwhelmed with the vocabulary that you hear in the
React world.
If you learn step by step, you\'ll begin to pretty soon get a very good
handle on all this vocabulary and you can easily go ahead and impress
people by throwing these words at them, and trying to impress them or
how much you know about React.
So, this is the jargon that you will end up learning also at the end of
this course.
Enough of the jargon.
Let\'s go ahead and get our hands dirty by starting to build a full
fledged React application, which will form part of all the exercises as
you go through the rest of this course.
We will start with our first exercise where we\'ll install the
create-react-app, which we will use to scaffold out our very first React
application in the first exercise, and then we will start building upon
this application throughout the remaining exercises of this course.
Exercise (Video): Getting Started with React
Now that we have examined React briefly in the previous two lectures,
I\'m sure you\'re curious about getting started with React, getting your
hands dirty with starting out on a React application.
So, in this exercise, we will look at how we will get started with
React. I\'m sure by now your computer is already configured with Note
and you have access to NPM, the package manager that comes with Note.
Exercise (Instructions): Getting Started with React
Objectives and Outcomes
In this first React exercise, you will first install create-react-app,
the command line tool for scaffolding React applications. You will then
use the tool to scaffold out a basic React application. We will
thereafter develop this application into a full-fledged React
application in the process of doing the exercises in this course. At the
end of this exercise you will be able to:
- Install create-react-app
- Scaffold out a basic React application
Installing Yarn
- Yarn is another package manager like NPM, but is better suited and
faster to work with for React applications. So let us install yarn
and use it for building our React applications.
- To install Yarn, you can find the instructions for your specific
platform at .
- If you choose not to install Yarn, you can continue to use npm in
place of yarn without any problem.
Installing create-react-app
From the React documentation we learn that the create-react-app CLI
makes it easy to create an application that already works, right out of
the box. It already follows the best practices suggested by the React
community!
- To install create-react-app globally, type the following at the
prompt:
```
$ yarn global add [email protected]
```
Use sudo on a Mac and Linux. Alternately you can use npm, by typing
\"npm install -g [email protected]\".
- This will make the command line tool for creating React
applications. To learn more about the various commands that this CLI
provides, type at the prompt:
```
$ create-react-app --help
```
Generating and Serving a React Project using create-react-app
- At a convenient location on your computer, create a folder named
React and move into that folder.
- Then type the following at the prompt to create a new React
application named confusion:
```
$ create-react-app confusion
```
- This should create a new folder named confusion within your
React folder and create the React application in that folder.
- Move to the confusion folder and type the following at the prompt:
```
$ yarn start
```
- This will compile the project and then open a tab in your default
browser at the address <Your Computer\'s Name>:3000.
- You can initialize your project to be a Git repository by typing the
following commands at the prompt:
```
$ git commit -m "Initial Setup"
$ git init
$ git add .
```
- Thereafter you can set up an online Git repository and synchronize
your project to the online repository. Make sure that the online Git
repository is a private repository.
Conclusions
In this exercise you installed the create-react-app CLI tool and created
a basic React project and served up the compiled project to your
browser.
React App Overview
Introduction to JSX
Exercise (Video): Configuring your React Application
Exercise (Instructions): Configuring your React Application
Objectives and Outcomes
In this exercise we will set up our project to use Reactstrap (a package
supporting easy to use React based Bootstrap 4 components). We will then
introduce our first reactstrap component into our application. At the
end of this exercise you will be able to:
- Configure your React project to use reactstrap.
- Start using reactstrap components in your application.
Configure your React Project to use Reactstrap
- To configure your project to use reactstrap, type the following at
the prompt to install reactstrap, and Bootstrap 4:
```
$ yarn add [email protected]
$ yarn add [email protected]
$ yarn add [email protected]
```
Note: You can also install the same using npm using the \"npm
install <package> \--save\" option if you are using npm instead of
yarn.
Configure to use Bootstrap 4
- Next, open index.js file in the src folder and add the following
line into the imports:
```
. . .
import 'bootstrap/dist/css/bootstrap.min.css';
. . .
```
Adding a Navigation Bar:
- Open App.js in the src folder and update it as follows:
```
class App extends Component {
render() {
return (
Ristorante Con Fusion
);
}
}
. . .
import { Navbar, NavbarBrand } from 'reactstrap';
. . .
```
- Do a Git commit with the message \"Configuring React\"
Conclusions
In this exercise we learnt to configure our React application to use
Reactstrap.
Introduction to React: Additional Resources
PDFs of Presentations
1-JavaScript-Frameworks.pdf
PDF File
2-Intro-React.pdf
PDF File
3-React-App-Overview.pdf
PDF File
4-Intro-JSX.pdf
PDF File
- [Framework](https://en.wikipedia.org/wiki/Software_framework)
- [Hollywood
Principle](https://en.wikipedia.org/wiki/Hollywood_principle)
- [Inversion of
Control](https://en.wikipedia.org/wiki/Inversion_of_control)
- [Imperative vs Declarative
Programming](https://netguru.co/blog/imperative-vs-declarative)
- [Imperative vs
Declarative](http://latentflip.com/imperative-vs-declarative)
Blog Articles
- [5 Best JavaScript Frameworks in
2017](https://hackernoon.com/5-best-javascript-frameworks-in-2017-7a63b3870282#.tt1k09l1d)
- [Top JavaScript Frameworks & Topics to Learn in
2017](https://medium.com/javascript-scene/top-javascript-frameworks-topics-to-learn-in-2017-700a397b711#.pe809bf0u)
- [Declarative vs. Imperative Programming for the
Web](http://codenugget.co/2015/03/05/declarative-vs-imperative-programming-web.html)
- [Is React library or a
framework?](https://develoger.com/is-reactjs-library-or-a-framework-a14786f681a0)
- [Is React a library or a framework and
why?](https://www.quora.com/Is-React-a-library-or-a-framework-and-why)
- [An Introduction to the React
Framework](https://www.upwork.com/hiring/development/an-introduction-to-the-react-framework/)
- [React is a
framework](https://www.sohamkamani.com/blog/2016/11/16/react-is-a-framework/)
- [Why isn\'t React called framework? What does it lack to be a
framework?](https://hashnode.com/post/why-isnt-react-called-framework-what-does-it-lack-to-be-a-framework-ciwm324og010xzx53wjfq354i)
React Components: Objectives and Outcomes
In this lesson you will learn about React components and how we
construct an React component and design its views. At the end of this
lesson you will be able to:
- Create a React component
- Construct the React component code and the view for your component
using JSX and JavaScript
React Components
Exercise (Video): React Components Part 1
Exercise (Instructions): React Components Part 1
Exercise Resources
images
ZIP File
Objectives and Outcomes
In this exercise you will add the first component to your React
application and update its view using JSX. At the end of this exercise
you will be able to:
- Add components to your React application
- Use JSX to define the views of your component.
Adding a Menu Component
- First, download the images.zip file provided above and then unzip
the file. Create a folder named assets in the public folder.
Move the resulting images folder containing some PNG files to the
React project\'s public/assets folder. These image files will be
useful for our exercises.
- Next, add a new folder named components in the src folder, and
create a new file named MenuComponent.js in this folder.
- Add the following code to MenuComponent.js:
```
this.state = {
dishes: [
{
id: 0,
name:'Uthappizza',
image: 'assets/images/uthappizza.png',
category: 'mains',
label:'Hot',
price:'4.99',
description:'A unique combination of Indian Uthappam (pancake) and Italian pizza, topped with Cerignola olives, ripe vine cherry tomatoes, Vidalia onion, Guntur chillies and Buffalo Paneer.' > },
{
id: 1,
name:'Zucchipakoda',
image: 'assets/images/zucchipakoda.png',
category: 'appetizer',
label:'',
price:'1.99',
description:'Deep fried Zucchini coated with mildly spiced Chickpea flour batter
accompanied with a sweet-tangy tamarind sauce' },
{
id: 2,
name:'Vadonut',
image: 'assets/images/vadonut.png',
category: 'appetizer',
label:'New',
price:'1.99',
description:'A quintessential ConFusion experience, is it a vada or is it a donut?' },
{
id: 3,
name:'ElaiCheese Cake',
image: 'assets/images/elaicheesecake.png',
category: 'dessert',
label:'',
price:'2.99',
description:'A delectable, semi-sweet New York Style Cheese Cake, with Graham
cracker crust and spiced with Indian cardamoms' }
class Menu extends Component {
constructor(props) {
super(props);
import React, { Component } from 'react';
import { Media } from 'reactstrap';
```
- Next, open App.js file and update it as follows:
```
. . .
import Menu from './components/MenuComponent';
. . .
. . .
```
- Open App.css file and delete all its contents.
- Save all changes and do a Git commit with the message \"Components
Part 1\".
Conclusions
In this exercise we added a new component to our React application,
added data to its class, and then updated the app to show the
information in the web page.
React Components: State and Props
Exercise (Video): React Components Part 2
Exercise (Instructions): React Components Part 2
Objectives and Outcomes
In this exercise we will continue modifying the menu component from the
previous exercise. Instead of a list, we will use a Card component from
reactstrap to display the menu in a different way. Also we will use the
Card component to display the details of a selected dish. At the end of
this exercise you will be able to:
- Make use of the Card component to display a list of items.
- Use the Card component to display detailed information.
Exercise Resources
dishes
JS File
Updating the Menu Component
- Open MenuComponent.js and update its contents as follows. Note
that we have removed the dishes variable from the state of the
component, and updated it to use the Card:
```
> constructor(props) {
> super(props);
> this.state = {
> selectedDish: null
> }
> }
> onDishSelect(dish) {
> this.setState({ selectedDish: dish});
> }
> renderDish(dish) {
> if (dish != null)
> return(
>
>
>
> {dish.name}
> {dish.description}
>
>
> );
> else
> return(
>
> );
> }
> render() {
> const menu = this.props.dishes.map((dish) => {
> return (
>
> class Menu extends Component {
> import { Card, CardImg, CardImgOverlay, CardText, CardBody,
> CardTitle } from 'reactstrap';
> . . .
```
- Add a folder named shared under the src folder.
- In the shared folder, create a new file named dishes.js and add
the following content to it (Note: Alternately you can download
the dishes.js file given above in the Exercise Resources and move
it to the shared folder. Make sure the file is named dishes.js):
```
> export const DISHES =
> [
> {
> id: 0,
> name:'Uthappizza',
> image: 'assets/images/uthappizza.png',
> category: 'mains',
> label:'Hot',
> price:'4.99',
> description:'A unique combination of Indian Uthappam (pancake) and Italian pizza, topped with Cerignola olives, ripe vine cherry tomatoes, Vidalia onion, Guntur chillies and Buffalo Paneer.',
> comments: [
> {
> id: 0,
> rating: 5,
> comment: "Imagine all the eatables, living in conFusion!",
> author: "John Lemon",
> date: "2012-10-16T17:57:28.556094Z"
> },
> {
> id: 1,
> rating: 4,
> comment: "Sends anyone to heaven, I wish I could get my mother-in-law to eat it!",
> author: "Paul McVites",
>
> date: "2014-09-05T17:57:28.556094Z"
> },
> {
> id: 2,
> rating: 3,
> comment: "Eat it, just eat it!",
> author: "Michael Jaikishan",
> date: "2015-02-13T17:57:28.556094Z"
> },
> {
> id: 3,
> rating: 4,
> comment: "Ultimate, Reaching for the stars!",
> author: "Ringo Starry",
> date: "2013-12-02T17:57:28.556094Z"
> },
> {
```
- Open App.js and update it as follows:
```
> . . .
> import { DISHES } from './shared/dishes';
> . . .
> class App extends Component {
> constructor(props) {
> super(props);
> this.state = {
> dishes: DISHES
> };
> }
> . . .
>
> . . .
```
- Save the changes and do a Git commit with the message "Components Part 2".
Conclusions
In this exercise we used a list of Cards to display the information in
the menu component. Also, we used a card to display the details of a
selected dish.
React Components: Lifecycle Methods Part 1
React Components: Additional Resources
PDFs of Presentations
5-Component-Part1.pdf
PDF File
6-Component-Part2.pdf
PDF File
7-Lifecycle-Methods.pdf
PDF File
React Resources
- [React
Components](https://reactjs.org/docs/components-and-props.html)
- [React Component
State](https://reactjs.org/docs/state-and-lifecycle.html)
- [React Component
Props](https://reactjs.org/docs/components-and-props.html)
- [reactstrap Media
Object](https://reactstrap.github.io/components/media/)
- [React.Component and Lifecycle
Methods](https://reactjs.org/docs/react-component.html)
- [reactstrap Card](https://reactstrap.github.io/components/card/)
- [Bootstrap unstyled
list](http://getbootstrap.com/docs/4.0/content/typography/#unstyled)
- [React Dev Tools](https://github.com/facebook/react-devtools)
- [React Dev Tools Chrome
Extension](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi)
DeadlineOct 23, 11:59 PM PDT
It looks like this is your first peer-graded assignment. [Learn
more](https://learner.coursera.help/hc/articles/208279926-Submit-peer-reviewed-assignments)
Ready for the assignment?
You will find instructions below to submit.
In this assignment you will add a new component to the React application
to show the details of a selected dish. You will use the Card component
and the Bootstrap unstyled list component to prepare the view for this
new component.
Step-By-Step Assignment Instructions
less Objectives and Outcomes
In this assignment, you will continue to work with the React application
that you have been developing in the exercises. You will add a new
component named DishdetailComponent that will display the details
of a selected dish. You will then design the view for the component
using the card component. At the end of this assignment, you should have
completed the following tasks:
- Created a new DishdetailComponent and added it to your React application.
- Updated the view of the DishdetailComponent to display the details
of the selected dish using an reactstrap card component.
- Updated the view of the DishdetailComponent to display the list of
comments about the dish using the Bootstrap unstyled list component.
Assignment Requirements
This assignment requires you to complete the following tasks. Detailed
instructions for each task are given below. The picture of the completed
web page included below indicates the location within the web page that
will be updated by the three tasks.
Task 1
In this task you will be adding a new DishdetailComponent to your
React application and include the component into the menu component\'s
view so that the details of a specific dish are displayed there:
- Replace the card showing the selected dish in MenuComponent\'s view
with the DishdetailComponent, and make sure to pass the selected
dish information as props to the DishdetailComponent.
- Create a new DishDetail class in a file named
DishdetailComponent.js in the components folder
- Export the DishDetail class from this file so that it can be
imported in MenuComponent.js and used to construct the view of
the selected dish.
- Return a <div> from the render() function. This <div> should use
the Bootstrap row class to position the content within the
<div>. This div will display both the details of the dish in a
Card and the list of comments side-by-side for medium to extra
large screens, but will stack them for xs and sm screens.
- The card should be enclosed inside a <div> appropriate Bootstrap
column classes so that it occupies the entire 12 columns for the
xs and sm screen sizes, and 5 columns for md screens and above.
Also apply a class of m-1 to this div.
- The comments should be enclosed in a <div> to which you apply
appropriate column classes so that it occupies the entire 12
columns for the xs and sm screen sizes, and 5 columns for md
screens and above. Also apply a class of m-1 to this div.
- If the dish is null then you should return an empty <div>
Task 2
In this task you will be adding a card component to the
DishdetailComponent view to display the details of the dish given
above:
- Implement a function named renderDish() that takes the dish as a
parameter and returns the JSX code for laying out the details of
the dish in a reactstrap Card. You have already seen this as part
of the MenuComponent class in the exercise earlier.
- Display the name of the dish as the Card title, and the description
as the Card text.
Task 3
In this task you will use the comments that are included in the dish
object above to display a list of the comments for the dish. Please use
your JavaScript knowledge to recall how you would access an inner
property in a JavaScript object that itself points to an array of
JavaScript objects (comments). This task involves the following steps:
- Implement a function named renderComments() that takes the comments
array as a parameter and lays out each comment as shown in the
image below. You should use the Bootstrap list-unstyled class on
the list.
- Each comment should be displayed on two lines, the first one showing
the comment, and the second line showing the comment author\'s
name and the date.
- The comments should contain a <h4> header with the word
\"Comments\".
- Remember to enclose the header and comments inside a <div> before
returning the JSX code. Otherwise React will not do the layout
correctly.
- If the comments are null, then you should return an empty <div>.
Review criteria
less
Upon completion of the assignment, your submission will be reviewed
based on the following criteria:
Task 1:
- A new DishdetailComponent has been added to your React
> application.
- Included the DishDetail into your MenuComponent\'s view to show the
> selected dish.
- Passing the selected dish as props to the DishDetail Component.
- Used the appropriate Bootstrap classes to the card so that it
> occupies the entire row for xs and sm screen sizes, and 5 columns
> for md screens and above.
- Used the appropriate Bootstrap classes to the div containing the
> list of comments so that it occupies the entire row for xs and sm
> screen sizes, and 5 columns for md screens and above.
Task 2:
- Used the Card component to display the details of the dish.
Task 3:
- Included a list of comments about the dish into the dishdetail view.
The first step in your journey towards the implementation of the
Capstone project begins with an idea. In this module you will develop
the idea for your project, the set of expected features, survey the
market to look at similar ideas to enable you to differentiate your
project from others, while at the same time drawing inspiration from
them. You are required to submit a formal ideation report following the
structure given in the template. This will enable your peers to provide
you feedback and suggestions for your project.
Before you get started on a project, the first step is to develop the
idea for the project. In this module you will explore how you develop
your idea and come up with possible set of features for your project. At
the end of this step you should be able to:
- Clearly express the central idea of your project, and identify the
problem being addressed
- Delineate a set of features that you expect your website and app
should support
- Identify other projects that might have similar features and would
act as exemplars for your project
Ideation Report Template
Project Title
1. Introduction
- A brief introduction to your website idea. State the goals of the
project.
- The values / benefits (tangible and intangible) this application can
bring to a company/organization/end-user.
2. Expected List of Features
- A brief list of features that you expect your website to support.
- Brief justifications for including these features.
3. Market Survey
- Do a survey of the Web to find about five web sites that might have
similar ideas as yours.
- Briefly compare the features of these applications with your
application idea.
4. References
- Give references to any material / websites / books etc. relevant to
your application idea
- Give the links to the websites relevant to your idea, that you
listed in the section above.
Honors Peer-graded Assignment: Ideation
DeadlineOct 23, 11:59 PM PDT
Ready for the assignment?
You will find instructions below to submit.
In this assignment you will be submitting a written report describing
the general idea of your project, the expected list of features and a
survey of existing projects, websites and/or apps that are similar to
your ideas and/or have some features similar to your proposed project.
The structure of the written report should adhere to the report template
given in this module, and emphasize the points specified in the
template. The written submission needs to be no more than three standard
Letter/A4 sized pages.
Review criteria
less
Your submission will be reviewed based on the following criteria by
peers in order to provide you with constructive feedback on your project
idea:
1. Does the Ideation report clearly state the idea of the project and
> the primary aim and purpose of the proposed website ?
2. Does the Ideation report list the expected features that will be
> supported by the website?
3. Did the user provide a survey of related ideas/projects/websites
> that have some similarities to the proposed idea?
4. Does the Ideation report provide references to suitable sources in
> support of the project idea?
Module 6: React Component Types: Objectives and Outcomes
In this lesson you will learn about various types of React components:
Presentational, Container and Functional components. At the end of this
lesson you will be able to:
- Identify the salient features and uses for the various types of
components
- Create presentational, container and functional components in your
React application
Presentational and Container Components
Notes
Exercise (Video): Presentational and Container Components
Exercise (Instructions): Presentational and Container Components
Objectives and Outcomes
In this exercise we understand about how presentational components deal
with the look and feel of the app and container components deal with the
data and behavior. At the end of this exercise you will learn about:
- Organizing your React app into presentational and container
components
- Enable your presentational components to be concerned with the look
and feel of your app
- Enable container components to deal with the state, provide the data
and handle user interactions.
Add a Container Component
- Add a new component named MainComponent.js in the components
folder and update its contents as follows:
```
> import React, { Component } from 'react';
> import { Navbar, NavbarBrand } from 'reactstrap';
> import Menu from './MenuComponent';
> import DishDetail from './DishdetailComponent';
> import { DISHES } from '../shared/dishes';
>
> class Main extends Component {
>
> constructor(props) {
> super(props);
> this.state = {
> dishes: DISHES,
> selectedDish: null
> };
> }
>
> onDishSelect(dishId) {
> this.setState({ selectedDish: dishId});
> }
>
> render() {
> return (
>
>
>
> Ristorante Con Fusion
>
>
>
> );
> }
> }
>
> export default Main;
```
- Update the App.js by removing the state related information, and
make use of Main Component to render the UI:
```
> . . .
> import Main from './components/MainComponent';
>
> class App extends Component {
>
> render() {
> return (
>
>
>
> );
> }
> }
>
> . . .
```
Turn Menu Component into a Presentational Component
- Open MenuComponent.js and update its contents by removing the state
and removing the DishdetailComponent reference, and make use of the
onClick supplied by MainComponent through the props to deal with the
clicking of a menu item:
```
> . . .
> onClick={() => this.props.onClick(dish.id)}>
> . . .
```
- The DishdetailComponent is already structured as a presentational
component and hence needs no further update, except wrapping the
return value from render() within a <div> with the className as
container.
- To print out the date for a comment in a format more suitable for
human readability, you can update your renderComment function with
the code snippet shown below:
```
> {new Intl.DateTimeFormat('en-US', { year: 'numeric', month: 'short', day: '2-digit'}).format(new Date(Date.parse(comment.date)))}
```
- Save all the changes and do a Git commit with the message
"Presentational and Container Components"
Conclusions
In this exercise you learnt how to structure your app into
presentational and container components.
React Components: Lifecycle Methods Part 2
Functional Components
Exercise (Video): Functional Components
Exercise (Instructions): Functional Components
Objectives and Outcomes
In this lesson we explore the design of functional components in React.
We will reimplement both the MenuComponent and DishdetailComponent as
pure functional components. At the end of this exercise you will be able
to:
- Implement functional components in React
- Illustrate the reimplementation of presentational components as pure
functional components
Implementing Functional Components
- Open MenuComponent.js and update it as follows:
```
> import React from 'react';
> import { Card, CardImg, CardImgOverlay,
> CardTitle } from 'reactstrap';
>
> function RenderMenuItem ({dish, onClick}) {
> return (
> onClick={() => onClick(dish.id)}>
>
>
> {dish.name}
>
>
> );
> }
>
> const Menu = (props) => {
>
> const menu = props.dishes.map((dish) => {
> return (
>
>
>
> );
> });
>
> return (
>
>
> {menu}
>
>
> );
> }
>
> export default Menu;
```
- Then open DishdetailComponent.js and update it as follows:
```
> import React from 'react';
> import { Card, CardImg, CardText, CardBody,
> CardTitle } from 'reactstrap';
> function RenderDish({dish}) {
> . . .
> }
> function RenderComments({comments}) {
> . . .
> }
> const DishDetail = (props) => {
> . . .
> }
> export default DishDetail;
```
- Save all the changes and do a Git commit with the message
"Functional Components".
Conclusions
In this exercise we have learnt to implement our components as pure functional components.
React Component Types: Additional Resources
PDFs of Presentations
1-Component-Types-Part1.pdf
PDF File
2-Component-Types-Part2.pdf
PDF File
Other Resources
- [Presentational and Container
Components](https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0)
- [Presentational and Container Components (Redux
Perspective)](https://redux.js.org/basics/usage-with-react)
- [React Component
Patterns](https://levelup.gitconnected.com/react-component-patterns-ab1f09be2c82)
- [Functional Stateless Components in
React](https://javascriptplayground.com/functional-stateless-components-react/)
Module 8: React Router: Objectives and Outcomes
In this lesson we cover the basics of React router. We examine how the
router enables the navigation among views of various components that
form part of a React application. At the end of this lesson you will be
able to:
- Set up the router module to enable navigation among multiple
component views
- Set up the routes to enable the navigation
React Virtual DOM
Exercise (Video): Header and Footer
Exercise (Instructions): Header and Footer
Objectives and Outcomes
In this exercise you will add in a header and a footer to our React
application using two React components. This will illustrate the use of
multiple components put together form the application\'s view. You will
also add in the Font Awesome icons and Bootstrap-social for use within
your application. At the end of this exercise you will be able to:
- Use multiple components and their views to put together the view of
the application.
- Make use of Font Awesome icons and Bootstrap-social within your
React application
Using Font Awesome Icons and Bootstrap-Social
- First use yarn or npm to fetch Font Awesome and Bootstrap-social to
the project by typing the following at the prompt:
```
> yarn add [email protected]
> yarn add [email protected]
```
- Then, open index.js file and update it as follows to enable your
application to use Font Awesome and Bootstrap Social:
```
> . . .
>
> import 'font-awesome/css/font-awesome.css';
> import 'bootstrap-social/bootstrap-social.css';
>
> . . .
```
Adding a Header and a Footer
- Create a new file named HeaderComponent.js and add the following to
it:
```
> import React, { Component } from 'react';
> import { Navbar, NavbarBrand, Jumbotron } from 'reactstrap';
>
> class Header extends Component {
> render() {
> return(
>
>
>
> Ristorante Con Fusion
>
>
>
>
>
>
>
Ristorante con Fusion
>
We take inspiration from the World's best cuisines, and create a unique fusion experience. Our lipsmacking creations will tickle your culinary senses!
>
>
>
>
>
> );
> }
> }
>
> export default Header;
```
- Then, add another file named FooterComponent.js and add the
following to it:
```
> import React from 'react';
>
> function Footer(props) {
> return(
>
>
> 121, Clear Water Bay Road
> Clear Water Bay, Kowloon
> HONG KONG
> : +852 1234 5678
> : +852 8765 4321
> :
> [email protected]
>
>
>
>
>
>
>
>
>
>
>
>
>
>
```
Integrating Header and Footer into the React Application
- Now we open MainComponent.js and update it to integrate the header
and footer into our application:
```
> . . .
>
>
>
> import Header from './HeaderComponent';
>
> import Footer from './FooterComponent';
>
>
>
> . . .
>
>
>
>
>
>