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

  • Redux Quick Start Guide
  • James Lee Tao Wei Suresh Kumar Mukhiya
  • 162字
  • 2021-07-02 12:40:32

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/.

主站蜘蛛池模板: 新建县| 北宁市| 利川市| 阿克陶县| 保亭| 丰原市| 曲松县| 蒙山县| 东宁县| 乌海市| 眉山市| 开阳县| 利津县| 文水县| 宁南县| 沧州市| 中方县| 股票| 德格县| 读书| 宣城市| 惠水县| 阜平县| 桦南县| 平和县| 涿鹿县| 克东县| 宁陵县| 大方县| 宣化县| 林口县| 体育| 海晏县| 清镇市| 泌阳县| 九台市| 涞水县| 个旧市| 罗甸县| 定边县| 通榆县|