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

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.

主站蜘蛛池模板: 都昌县| 那曲县| 宣武区| 西华县| 泸州市| 秭归县| 彭州市| 六盘水市| 卢龙县| 宿迁市| 岳池县| 邹城市| 永年县| 米易县| 昌图县| 宁陵县| 兴安盟| 胶南市| 红桥区| 屏南县| 阿坝县| 上杭县| 佛学| 利辛县| 那坡县| 绥阳县| 工布江达县| 青阳县| 德惠市| 屏东县| 哈密市| 辉县市| 饶河县| 台安县| 哈密市| 凌云县| 囊谦县| 彭泽县| 丹江口市| 东山县| 千阳县|