@@ -20,28 +20,30 @@ Install [Node.js and npm](https://nodejs.org/en/) (v6.6.0) if they are not alrea
2020installed on your computer.
2121
2222> Verify that you are running at least node v6.x.x and npm 3.x.x by running ` node -v ` and ` npm -v `
23- in a terminal/console window. Older versions may produce errors.
23+ > in a terminal/console window. Older versions may produce errors.
2424
2525## Steps to build it
2626
2727- Copy the content of the ` 02 Components ` folder to an empty folder for the sample.
2828
2929- Install the npm packages described in the ` package.json ` and verify that it works:
3030
31- ``` bash
32- $ npm install
33- ```
31+ ``` bash
32+ $ npm install
33+ ```
3434
3535- Install ` react-router-dom ` and typings:
3636
3737``` bash
3838npm install react-router-dom --save
3939npm install @types/react-router-dom --save-dev
40+ npm i @types/node
4041```
4142
4243- Update ` vendors ` :
4344
4445### ./webpack.config.js
46+
4547``` diff
4648...
4749entry: {
@@ -62,30 +64,31 @@ entry: {
6264- Now, we can start adding a dummy ` Members Page ` :
6365
6466### ./src/components/members/page.tsx
67+
6568``` javascript
66- import * as React from ' react' ;
69+ import * as React from " react" ;
6770
6871export const MembersPage: React .StatelessComponent <{}> = () => {
6972 return (
7073 < div className= " row" >
7174 < h2> Members Page< / h2>
7275 < / div>
7376 );
74- }
75-
77+ };
7678```
7779
7880- And its ` index.ts ` file:
7981
8082### ./src/components/members/index.ts
81- ``` javascript
82- export * from ' ./page' ;
8383
84+ ``` javascript
85+ export * from " ./page" ;
8486```
8587
8688- Update ` header ` component to add links to navigate other pages:
8789
8890### ./src/components/header.tsx
91+
8992``` diff
9093import * as React from 'react';
9194+ import { Link } from 'react-router-dom';
@@ -103,13 +106,12 @@ export const Header: React.StatelessComponent<{}> = () => {
103106+ <div className="collapse navbar-collapse" id="navbarSupportedContent">
104107+ <ul className="navbar-nav mr-auto">
105108+ <li className="nav-item">
106- + {/* <a className="nav-link" href="#">Home <span className="sr-only">(current)</span></a> */}
107109+ <Link className="nav-link" to="/about"> About</Link>
108110+ </li>
109111+ <li className="nav-item ">
110112+ <Link className="nav-link" to="/members"> Members </Link>
111- + </li>
112- + </ul>
113+ + </li>
114+ + </ul>
113115+ </div>
114116+ </nav>
115117 </div>
@@ -121,6 +123,7 @@ export const Header: React.StatelessComponent<{}> = () => {
121123- Update components ` index.ts ` file:
122124
123125### ./src/components/index.ts
126+
124127``` diff
125128export * from './header';
126129export * from './about';
@@ -133,11 +136,12 @@ export * from './about';
133136- Now, we are going to create the ` AppRouter ` component where we define routes:
134137
135138 ### ./src/router.tsx
139+
136140 ``` javascript
137- import * as React from ' react' ;
138- import { Route , HashRouter , Switch } from ' react-router-dom' ;
139- import { App } from ' ./app' ;
140- import { About , MembersPage } from ' ./components' ;
141+ import * as React from " react" ;
142+ import { Route , HashRouter , Switch } from " react-router-dom" ;
143+ import { App } from " ./app" ;
144+ import { About , MembersPage } from " ./components" ;
141145
142146 export const AppRouter: React .StatelessComponent <{}> = () => {
143147 return (
@@ -152,7 +156,7 @@ export * from './about';
152156 < / div>
153157 < / HashRouter>
154158 );
155- }
159+ };
156160 ```
157161
158162 - The type of router that we are using is HashRouter because we are creating a static website.
@@ -163,6 +167,7 @@ export * from './about';
163167- Update ` App ` . We will remove the div enclosing ` Header ` because we have already added it in ` AppRouter ` :
164168
165169### ./src/app.tsx
170+
166171``` diff
167172import * as React from 'react';
168173- import { Header, About } from './components';
@@ -183,6 +188,7 @@ import * as React from 'react';
183188- And finally, update main file:
184189
185190### ./src/index.tsx
191+
186192``` diff
187193import * as React from 'react';
188194import * as ReactDOM from 'react-dom';
@@ -198,11 +204,11 @@ ReactDOM.render(
198204
199205- Execute the example:
200206
201- ``` bash
202- $ npm start
203- ```
207+ ``` bash
208+ $ npm start
209+ ```
204210
205211# About Lemoncode
206212
207213We are a team of long-term experienced freelance developers, established as a group in 2010.
208- We specialize in Front End technologies and .NET. [ Click here] ( http://lemoncode.net/services/en/#en-home ) to get more info about us.
214+ We specialize in Front End technologies and .NET. [ Click here] ( http://lemoncode.net/services/en/#en-home ) to get more info about us.
0 commit comments