- Redux Quick Start Guide
- James Lee Tao Wei Suresh Kumar Mukhiya
- 339字
- 2021-07-02 12:40:32
Configuring our app with Redux
This is the main file, app.js, which will be the main entry file for our project. We are going to put the file inside of app/app.js. You can see that we are using some of the npm packages, including @babel/polyfill, react, react-dom, react-redux, and sanitize.css:
// Needed for redux-saga es6 generator support
import "@babel/polyfill";
// Import all the third party stuff
import React from "react";
import ReactDOM from "react-dom";
import { Provider } from "react-redux";
import history from "utils/history";
import "sanitize.css/sanitize.css";
// Import root app
import App from "containers/App";
import configureStore from "./configureStore";
// Create redux store with history
const initialState = {};
const store = configureStore(initialState, history);
const MOUNT_NODE = document.getElementById("app");
const render = () => {
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
MOUNT_NODE
);
};
render();
Let's briefly go over these packages, as follows:
- @babel/polyfill (https://babeljs.io/docs/en/babel-polyfill): Babel polyfill has a polyfill that contains a custom regenerator runtime and core-js. In other words, it allows us to consume the full set of ES6 features, beyond syntax changes, including built-in objects like Promises and WeakMap, as well as new static methods, like Array.from or Object.assign.
- react: We already know what React is. We are going to dive deeper into creating React components in Chapter 6, Extending Redux by Middleware.
- react-dom: React DOM helps us to glue React and the DOM. When we want to show our React components on the DOM, we need to utilize this ReactDOM.render() function from React DOM. We will discuss these features more in the upcoming chapters.
- React-redux: This allows us to communicate, in both ways, between React and Redux (https://github.com/reactjs/react-redux). It is a binding between React and Redux that allows us to create containers and listen to the store changes, reflecting that into a presentational component. We will explore container components (smart components) and presentational components (dumb components) in more detail in upcoming chapters.
- Sanitize.css (https://github.com/csstools/sanitize.css): This is one of the cascading style sheet libraries that yield consistent, cross-browser default styling of HTML elements, as well as useful defaults.
推薦閱讀
- Flask Web全棧開(kāi)發(fā)實(shí)戰(zhàn)
- 解構(gòu)產(chǎn)品經(jīng)理:互聯(lián)網(wǎng)產(chǎn)品策劃入門(mén)寶典
- Node.js 10實(shí)戰(zhàn)
- iOS開(kāi)發(fā)實(shí)戰(zhàn):從零基礎(chǔ)到App Store上架
- ASP.NET Core 2 and Vue.js
- Java程序設(shè)計(jì)與實(shí)踐教程(第2版)
- MATLAB定量決策五大類(lèi)問(wèn)題
- 鋒利的SQL(第2版)
- JavaScript應(yīng)用開(kāi)發(fā)實(shí)踐指南
- Learning Node.js for .NET Developers
- Modern C++ Programming Cookbook
- Orleans:構(gòu)建高性能分布式Actor服務(wù)
- C語(yǔ)言程序設(shè)計(jì)實(shí)訓(xùn)教程與水平考試指導(dǎo)
- Hadoop大數(shù)據(jù)分析技術(shù)
- PHP項(xiàng)目開(kāi)發(fā)全程實(shí)錄(第4版)