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

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.

主站蜘蛛池模板: 恭城| 公安县| 宜昌市| 上林县| 沾化县| 昆山市| 广平县| 罗甸县| 淮南市| 台北县| 茶陵县| 广西| 洮南市| 麟游县| 宜都市| 西畴县| 平远县| 常熟市| 南宁市| 昆明市| 同德县| 肥东县| 天门市| 河西区| 静安区| 兴宁市| 泸水县| 余庆县| 贞丰县| 小金县| 西青区| 土默特右旗| 海丰县| 河南省| 江源县| 遵化市| 丹寨县| 南康市| 北宁市| 藁城市| 彭州市|