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

Creating the first container

Let's create our first container component, inside of app/containers/App/index.js:

import React from 'react';
import HomePage from 'containers/HomePage/Loadable';
export default function App() {
return (
<div>
<HomePage />
</div>
);
}

The home page container contains two files, Loadable.js and index.js:

import loadable from 'loadable-components';
export default loadable(() => import('./index'));

The index.js is as follows:

import React, { PureComponent } from 'react';
/* eslint-disable react/prefer-stateless-function */
export default class HomePage extends PureComponent {
render() {
return <h1>This is the HomePage Redux-book container!</h1>;
}
}

The complete code for this project can be found in the GitHub repository, inside of the CH01 starter files. We are going to continue using it in other chapters. Once you have these files up in your editor, we can start to run our first application. To run the application, the first thing to do is install the npm dependencies, as follows:

yarn install
yarn run

The application should start at http://localhost:8080/.

主站蜘蛛池模板: 苏尼特右旗| 平安县| 台前县| 安远县| 杭州市| 凭祥市| 五家渠市| 丰台区| 嘉兴市| 桐庐县| 苏尼特右旗| 松江区| 咸宁市| 荣昌县| 义乌市| 胶州市| 荆州市| 盐边县| 肇州县| 香港 | 抚州市| 项城市| 轮台县| 蓝田县| 贵阳市| 永顺县| 阳曲县| 桂林市| 平湖市| 奈曼旗| 平山县| 突泉县| 眉山市| 靖宇县| 澄江县| 肥东县| 阿勒泰市| 巧家县| 宿州市| 德钦县| 蒙城县|