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

Summary

React is a JavaScript library used to build user interfaces. Unlike libraries such as Angular and Ember, which include a routing package, the React library does not include any components or services that help in routing. React-Router is a routing library that can be used in any React application, web or native. React-Router version 4 is a complete rewrite of the earlier versions and all of its components are written in React. The library includes the packages react-router-dom for use in web applications; react-router-native, for use in native applications built with React-Native; and react-router, a core package that both react-router-dom and react-router-native have a dependency on. 

The create-react-app CLI is used to quickly scaffold a React application. It includes build configuration scripts that can be used to generate builds for development and production environments. The react-router-dom package is then added as a dependency to the application. The package includes the <BrowserRouter> component, which implements a History interface. The application's root component, <App />, is wrapped inside React-Router's <BrowserRouter> component to make the History object available to all the components in the application tree. 

To create our first route, the <Route> component is included. It accepts path and component as props, and renders the component when the browser's URL matches the <Route> path. 

In Chapter 2, Configuring Routes - Using Various Options in the Route Component, the <Route> component props are discussed in detail. Also, we will take a look at the various props that the rendered component receives, and consider how these props can be used to create nested routes.

主站蜘蛛池模板: 比如县| 凉山| 思茅市| 石景山区| 顺义区| 五家渠市| 辰溪县| 龙南县| 莱阳市| 河北省| 阿图什市| 屏山县| 龙门县| 郑州市| 博兴县| 云霄县| 通道| 揭东县| 壶关县| 惠安县| 定日县| 湛江市| 平乡县| 商城县| 资中县| 东丰县| 东平县| 乡城县| 南汇区| 新乡县| 永胜县| 奎屯市| 都兰县| 平潭县| 石阡县| 鸡西市| 光泽县| 将乐县| 嫩江县| 莱西市| 海盐县|