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

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.

主站蜘蛛池模板: 广灵县| 灵川县| 吉安县| 丰城市| 博罗县| 修文县| 仙居县| 习水县| 将乐县| 天峻县| 铜鼓县| 乌恰县| 定远县| 尖扎县| 岱山县| 舞阳县| 洛川县| 新河县| 潜山县| 水富县| 阿克陶县| 惠安县| 安义县| 鹤壁市| 公安县| 宜都市| 海丰县| 商洛市| 天津市| 中西区| 宜宾县| 扬州市| 额济纳旗| 上林县| 高安市| 荔波县| 高唐县| 双柏县| 拜泉县| 大关县| 巴彦县|