This is a template for a new React project. It includes all necessary bootstrap code to help you start writing your application logic immediately.
The purpose of this lesson is to learn the basics of a distributed version control, and deploy your first application to a hosted server. The exercises below will take you through the common operations using Git and Github, creating a Heroku server and deploying your application there. As a result you have also mastered writing a new React application using a template you could reuse and reproduce yourself. No magic involved.
- Create an account on Github
- Add your SSH public key to Github to be able to make changes
- Set your user information in your Git configuration
- Fork this repository
- Clone the forked repository to your computer
- Enter the cloned directory
- Run the code. If you need help, see Running the code below.
- Modify src/index.jsx
- Check what files have been changed (
git status
) - Add the changed files to staging area (
git add
) - Make a commit with a comment of the changes (
git commit
) - Save the changes to Github (
git push
)
- Try first yourself. If you need help, see Running this lesson in Heroku below.
Tip: You will need to set development environment (NPM_CONFIG_PRODUCTION) and (PORT) to run it correctly.
Write an application that collects a weather forecast from Eficode weather forecast. For that purpose you can use the instructions and API information here and e.g. fetch.
Release your application in Heroku.
If you feel like it, add geolocation to your application and fetch the forecast at the users's location.
- Install nodejs.
- Go to the project directory using a terminal / shell.
- Install dependencies
npm install
- Run the app
npm start
- Open browser in http://localhost:8000
- Install docker.
- Go to the project directory using a terminal / shell.
- Build the app
docker-compose build
(this is an optional step on the first time) - Run the app
docker-compose up
- Open browser in http://localhost:8000
- Install heroku cli
- Login to heroku on command line:
heroku login
- Create a new app. If name is left blank, heroku will generate one for you:
heroku create <name>
- See that heroku created a remote repository for you:
git remote -v
. - Tell heroku to install dependencies for development use:
heroku config:set NPM_CONFIG_PRODUCTION=false
- Tell the application to use port 80 instead of 8080:
heroku config:set PORT=80
- Push your code to heroku:
git push heroku master