官术网_书友最值得收藏!

Our app skeleton

First things first. Before we start building our React application, let's get set up with the basic HTML and CSS--the skeleton of our application, if you will, upon which we will heap the React muscles:

  1. Open up your Terminal and switch to whichever directory you want to store your project in.
  2. Then, we'll make our app directory with mkdir chatastrophe. Let's go inside that folder, make another folder within it named public, and within public, touch index.html. If you're on Windows, use type nul > index.html instead of touch:
  1. Then, open up the whole chatastrophe folder in your text editor of choice. I'll be using Sublime Text 3 for this tutorial. Open up the index.html file, and let's write some HTML!

 

  1. Let's start with the basic HTML elements. Create a <html> tag, and within that, <head> and <body>.
  2. This wouldn't be a programming tutorial without a hello world, so within the body, let's put Hello world! within an <h1> tag.
  3. Then, open up index.html within your browser:

Our goal by the end of the chapter is to display the exact same as the preceding illustration, but using React to render our <h1>.

Why did we put our index.html inside the public folder? Well, our HTML is the first thing our users will download when they hit our page. They will download it exactly as we see it here. This is in sharp contrast to our React JavaScript, which will be transpiled (more on that in the next chapter) before being served to the client. Our React code, as we write it, will be private. Our HTML, as we write it, will be public.

This is a distinction that will make more sense as we move into the React world, but for now, just know that the convention is to put HTML and static assets in the public folder.

主站蜘蛛池模板: 南和县| 邵阳县| 新竹县| 米泉市| 余干县| 揭东县| 凤山县| 泽库县| 阿尔山市| 犍为县| 吴桥县| 石林| 肃南| 改则县| 乌审旗| 合肥市| 措勤县| 措勤县| 宜兰县| 安顺市| 丹棱县| 青海省| 盈江县| 云梦县| 赤城县| 三原县| 乐平市| 共和县| 永丰县| 墨竹工卡县| 乌鲁木齐县| 铜川市| 台州市| 宁远县| 平罗县| 凤城市| 加查县| 隆化县| 浙江省| 色达县| 垣曲县|