02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Setting up our foundation project

In this foundational lesson, we prepare to dive into ReactJS development by setting up a complete project environment. This involves configuring essential tools like Node.js, NPM, and Webpack, and creating a basic HTML structure to serve as our project's skeleton.


Prerequisites

Before proceeding, ensure the following are installed and updated:

  • Node.js (version 6 or higher)
  • NPM (version 3 or higher)

You can check your versions using the following commands:

node -v  
npm -v  

If necessary, update Node.js and NPM from their respective websites.


Steps to Set Up the Project

1. Create the Project Folder

Start with an empty directory. Inside it, create a new folder structure:

  • A public/ folder for assets (e.g., images).

Commands:

mkdir public  
mkdir public/images  

2. Initialize the Project with NPM

Run the following command to initialize the project:

npm init  

This will launch an interactive setup. Accept the defaults or provide details such as the project name (bootstrapping-react) and version. This will generate a package.json file, which serves as the descriptor for your project.

3. Create the Basic HTML File

Inside the public/ folder, create an index.html file. Use the following structure:

<!DOCTYPE html>  
<html lang="en">  
<head>  
    <meta charset="UTF-8">  
    <meta name="viewport" content="width=device-width, initial-scale=1.0">  
    <meta http-equiv="X-UA-Compatible" content="IE=edge">  
    <title>Building React User Interfaces</title>  
</head>  
<body>  
    <div>  
        <h1>Building React User Interfaces</h1>  
        <p>With Bootstrap and SaaS</p>  
        <a href="#" target="_blank">Discover More</a>  
    </div>  
</body>  
</html>  

This file will serve as the basis for our React application.

4. Setting Up Webpack and a Dev Server

To enhance our workflow, we will integrate Webpack in the next step. Webpack allows hot reloading, ensuring that changes in our code instantly reflect in the browser.


Key Takeaways

  • You’ve successfully set up a basic project structure for ReactJS development.
  • The package.json file helps manage project dependencies.
  • The HTML structure you created will serve as the entry point for your React components.

In the next lesson, we will dive deeper into configuring Webpack and setting up a development server for a seamless ReactJS workflow.

Video Transcript

00:00Welcome to Mastering React User interfaces
00:03with Bootstrap 4.0 SaaS and Animation.
00:07My name is Ben Fala and this is a packed publishing.
00:10So before we even start, let's just define who you are.
00:14The one that is taking this title.
00:16You're a JavaScript developer.
00:17If a ES five one
00:19or an ES six one, you don't have to be an E ES 6 6 1.
00:23'cause every time when we talk about new E es six things,
00:26we'll also explain them even though it's not gonna be our
00:28main topic of this title.
00:31And you're a motivated problem solver.
00:33For one, before starting this title, you have
00:36to install a few things
00:37and there's a lot of documentation online for it.
00:40So you just have to install a few things.
00:41That's the big problem that you would need to solve.
00:44But generally speaking, you wanna solve
00:46things, you're motivated.
00:48Okay, so let's talk about
00:49what are the big stuff that we're gonna be covering?
00:51What are the main topics that we'll be covering?
00:53Our learning goals for this title, we'll learn how
00:56to build user interfaces in React.
00:59And as we do that, we're also going
01:01to integrate Bootstrap 4.0 into React
01:03and show you really that process of
01:06how do you integrate third party tools into React.
01:09Moreover than that, we're also going to explore SaaS
01:12and learn how the Syntex works, how
01:15to integrate it in the world of NPM
01:18and for that matter into the world of React
01:21until we create incredibly powerful modular components
01:25with dynamic CSS
01:27or more accurately dynamic CSS that is created by sas.
01:31And last but not least, our last big topic is gonna be
01:34learning how to animate within React.
01:36So by the end of these skills
01:37that you're gonna develop in this title,
01:39you're really gonna have all the core skills you need
01:42to create any user interface.
01:45With that said, what are the secondary learning goals
01:48and what other topics we'll be exploring?
01:50We'll be exploring the learning of React itself,
01:54although that's not our main focus.
01:55It's gonna be weaved throughout the title, learning about
01:58how React works and learning the different core competencies
02:02that you want to know about React, namely props, state
02:05and user interactions.
02:07We'll learn a little bit of ES six
02:09and JSX functionally based on what we need
02:12as we're building things out.
02:14And we're also gonna explore webpac, Webpac dev server
02:17and hot reloading to understand how to get our site
02:20to run the best in the best packager possible
02:23to save us time as we're developing
02:25and building out our application.
02:27With that said, let's take a short overview
02:30of the different chapters
02:32and se well sections that exist within this title.
02:34There are five sections when in the first section we'll
02:37focus on bootstrapping React,
02:39and in other words, we're really gonna set everything up.
02:41We're gonna learn about the project itself
02:43that we'll be using with Bootstrap.
02:44And we're also create our first React component using JSX.
02:50Our second section is gonna be focused on react components
02:54as we focus on building out ES six classes
02:58that are react components.
02:59So in the process we'll learn quite a lot
03:01of ES six in chapter two.
03:04Our third section is gonna be all about creating one
03:07component from start to finish
03:08and making it really brilliant
03:10and dynamic as we merge between bootstrap ES six
03:14and React components
03:15to create a really perfect jumbotron react component
03:19that could be used for production already.
03:22Chapter four or section four is gonna be all about SaaS
03:26as we integrate SaaS into our bootstrap
03:29and react components.
03:31Really powerful stuff making our CSS dynamic as well.
03:35Last but not least, in our final section we'll focus on
03:38animation and make our components just look
03:40better as they animate.
03:42In our first section as we're saying,
03:44we're gonna bootstrap react
03:45and in the process we'll familiarize ourselves with Webpack
03:48and the Webpack dev server
03:50as we create a hot reloading application
03:53that every time we make any change in our code,
03:56we'll automatically update in our browser as well.
03:59To save us time, we're also gonna add loader support
04:03for ES six and JSX in our web pack
04:05and understand how that works.
04:07And last but not least, we're also gonna build out our first
04:10JSX React component.
04:12Well, in this lecture our focus is gonna be setting up
04:15our foundation project.
04:17So with that said, before you really start watching this
04:20lecture, make sure you install no JS
04:22because once we're done with this intro, we're assuming
04:25that you've installed no JS and NPM
04:28and they're kind of working well,
04:29not kind of really working.
04:31And we're gonna start in this lecture,
04:33a new project with NPM.
04:34We're gonna see how to create a new project
04:36and what that actually means
04:38as we build out our core HTML structure
04:41that we're gonna be using throughout the
04:42remainder of this title.
04:44So let's jump right into our first lecture
04:47as we set things up.
04:49Welcome, welcome. And we're starting off
04:52with a completely empty folder
04:54and I'm assuming you know the basics
04:56Of Working with terminal beyond that.
04:58Also, to be able to take this title, you have to make sure
05:01that you've installed node js
05:04and NPM when you go onto the node js website.
05:08When you install node, JSO will automatically install
05:11for you NPM as well.
05:13But if you already had an earlier
05:14Version, make sure to check that you have a version that
05:17Is six or above. And
05:18if not, go
05:20And update your Version of Node.
05:23Same applies for NPM.
05:24Make sure that you have a version that is three or above
05:27and if you do, you're good.
05:28If not, go onto the NPM site to learn how
05:31to update your NPM.
05:33With that said, I'm gonna assume that we have a running node
05:36and a running NPM and everything is working.
05:39And from there on let's start
05:41Building our project. So as I said, I'm
05:42Starting off from a completely empty folder
05:45and what I wanna do is I want to go ahead and create a few
05:49Directories, really Starting off with one directory
05:52and I'm gonna create the directory, uh,
05:55which will be called public Public
05:59and it will have inside of it an image folder.
06:01So created the next step
06:04that I'm gonna do is I wanna start up
06:06and create an MPM skeleton website.
06:11Well project more accurately or module more accurately.
06:14To do that, I'm gonna type NPM
06:18in it and type enter.
06:20Once I've done that, it's going to walk me through
06:24an interview which I could then fill up.
06:26For example, for this project, I'm gonna call this,
06:28yeah, that sounds good to me.
06:30Bootstrapping react, that's beautiful.
06:32Where in version one I'm not gonna put a description.
06:35Our entry point is fine.
06:37I'm gonna leave the defaults really as they are
06:39and just scan through them and keep them as they are.
06:42Everything looks good to me and I'm gonna click on yes.
06:45Once I've done this and I went through the interview,
06:48you'll see that if you look into the directory, you'll see
06:50that we'll have your our package that SON,
06:53and we're gonna have our public folder
06:56Now package Do js ON is really the descriptor
06:59of our everything that we're doing
07:02and what it literally does, it basically creates for us a
07:08skeleton for our application
07:10that then tells whoever else will be using it in the future.
07:14What are the things that we expect for it to have
07:16and what is this package making it easier for us
07:19to package it up and move it around that way.
07:22Excuse me for that beep.
07:24So one of the things
07:25that we're gonna do in this process is set up a virtual host
07:30or really a a client side host.
07:32So we'll be able to run our files.
07:34But before we do that, now
07:36that we set up our initial PA package, I just want
07:39to go ahead and create our basic HTML.
07:42Now to do that, I'm just gonna go ahead
07:43and I'm gonna touch the file inside of our public folder,
07:48creating an index html file.
07:51Once that file is created, I'm gonna go into my editor.
07:54And in my editor I'm just gonna go right into that
07:58new image file that has been created and let's go ahead
08:01and start creating that document.
08:04So first of all, I'm gonna start off with our HTML
08:07by creating a new doc type
08:10and defining it as an HTML five doc type
08:13by just typing HTML.
08:15So basically what I'm telling the browser is this website is
08:18HTML five compliant.
08:20The next step is I'm gonna create my HTML
08:23and give it a language.
08:25So it's gonna be in English.
08:26So whoever's gonna read this will know
08:28that this is an English speaking website
08:31and I'll create my head, which I'm sure you're familiar with
08:34that and create My body,
08:36which I'm sure you're familiar with that as well.
08:40Let's go ahead and note, so set up in our head
08:42or our metadata.
08:43So let me just set here our meta char set
08:46and set it to be UTF eight.
08:50And let's make sure
08:52that our website also supports the latest.
08:55Well more accurately, what
08:56what do I wanna do is I'm gonna call HETP Equi HTP dash
09:01equi and I'm gonna set it to be equal to X uua
09:07compar com comparable.
09:11Now what that is basically is a directive that is implied
09:14for Internet Explorer
09:16and we're gonna tell Internet Explorer to what version
09:20of Internet Explorer was the site built for.
09:23And in our case, we're gonna set our content
09:25to tell Internet Explorer
09:27or more accurately to tell Edge that new version
09:30that our website is that edge.
09:33It's customized for Edge, so it doesn't have to create
09:36an inter explorer.
09:38Whenever a website comes up, inter Explorer decides if it
09:40was built for older versions of IE or for newer ones.
09:44And then it dynamically decides
09:45that in our case we're avoiding that situation
09:48by basically telling the browser, use the edge,
09:51use the modern version.
09:53Okay, so with that said, I'm gonna go ahead and put your OTO
09:56because our, we're living in that modern world.
09:59I want to tell mobile devices that our,
10:02and let me, let me just oto set here name
10:05and I'm just gonna copy paste this a few times
10:07'cause we're gonna have a few of these that we're gonna be
10:09putting in and also content
10:11and we have a few of those coming in as well.
10:14So let me just copy paste that three times
10:17'cause we're gonna be putting three different ones.
10:19And in this case, the first one
10:20that I wanna set is the Viewport
10:23and the Viewport property basically tells the browser
10:28that the content inside of your mainly really relatable
10:32to mobile devices is how should it treat the content?
10:35Because earlier mobile devices
10:37and still mobile devices, what they tend
10:39to do is they take all the content
10:41and pretend it's on a size of 1280 because that's the size
10:45or 10 80, that's a size where a lot of content is visible
10:48and then it shrinks it down to fit into the browser.
10:52But because we are aware of that
10:54and we're building our site to be mobile compatible,
10:57then we're gonna go ahead
10:58and say to the device, use the device with as that width,
11:03don't use a random width the you decide
11:06and set that initial scale to be scale.
11:12What am I doing? Scale equals one again.
11:15So what I'm basically telling that browsers are a mobile,
11:18mainly make sure that you use the your starting
11:21with don't re really don't scale things up,
11:24set it in its normal scale
11:26and set the viewport with content to be the width
11:29of the device itself.
11:30Making sure that the browser itself is not gonna manipulate
11:33our content, but will be in charge of that manipulation.
11:37Now let's just add your oats on Author,
11:40not that it's mandatory.
11:42And my name is Ben Fallas, I'm that author.
11:45And let's Otto put your description,
11:51which in a real world scenario, I would go ahead
11:54and put here some sort of a description.
11:56Last but not least, let's give ourselves a
11:58title for our header.
12:01And I'm just gonna put here our tentative title name
12:06for this title and just put it right inside
12:10our HTML.
12:12Beautiful. So we set up our basic core structure
12:15of our HTML.
12:16Let's go ahead and create our body as well.
12:19And to do that, I'm just gonna go into my body
12:21and I'm gonna create, or a diviv.
12:23Now I'm gonna be using Bootstrap really to design it.
12:26So I'm not gonna worry at all about design,
12:28but I know it's gonna be a leader.
12:31Uh, really what I want is something
12:32that's gonna take over our full screen
12:34and I'm just gonna go ahead here
12:35and I'm gonna create an H one
12:37and I'm going to create a paragraph.
12:41Let's just create that and we're gonna create two of those.
12:45So let's go ahead and place that in there.
12:48And I'm gonna put for our headline, let's call this
12:53building React User interfaces with
13:00Bootstrap and SaaS.
13:04Hmm. That's what we're gonna be covering in this title.
13:06And let's just go ahead and put your Otto a link.
13:09So let's go ahead
13:10and just put your A link, which will turn into a button once
13:12we're starting to use React.
13:14And I'm just gonna type here discover things.
13:19Last but not least, let's put it a a, a link.
13:22So let's have people go to my website
13:29or making sure that it opens to them in a blank window.
13:36Beautiful. So that's it.
13:38We have here a basic structure of our HTML
13:41and if we just go to a browser
13:43and load it up, we should have basically our basic structure
13:47building React user interfaces very, very plain.
13:50But really our goal is for it to take the full screen
13:53and for it to be visual, which we'll use Bootstrap for that.
13:57But before we really even could use Bootstrap,
13:59what we really wanna do is we wanna not approach our file
14:03as a file as we're doing right now
14:05by literally just taking a file and viewing it directly.
14:09Really, when you're working in development, you wanna work
14:11with servers and that's exactly what we're gonna use NPM
14:15for right now because in the next lecture we're gonna use
14:18NPM with the help of webpac to create a dev server
14:23that is a node dev server that will run in the background.
14:25So we will have a real environment
14:28so we could test our application out in a real
14:31environment type setup.
14:34In this lecture, we set things up.
14:36Now that everything is more
14:37or less ready as a project, it's time for us to move on
14:42to set up and move to create a server, which is exactly
14:45what we're gonna do in the next lecture.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!