- Advanced TypeScript Programming Projects
- Peter O'Hanlon
- 225字
- 2021-06-24 13:27:12
Adding Bootstrap support
One of the things we need to do with our application is bring in support for Bootstrap. This is not something that is provided out of the box with React, so we need to add this capacity using other packages:
- Install Bootstrap as follows:
npm install --save bootstrap
- With this in place, we are now free to use a React-ready Bootstrap component. We are going to use the reactstrap package because this package targets Bootstrap 4 in a React-friendly fashion:
npm install --save reactstrap react react-dom
- reactstrap is not a TypeScript component, so we need to install the DefinitelyTyped definition for this and for Bootstrap:
npm install --save @types/reactstrap
npm install --save @types/bootstrap
- With this in place, we can now add the Bootstrap CSS files. To do this, we are going to update the index.tsx file by adding a reference to our locally installed Bootstrap CSS file, by adding the following import to the very top of the file:
import "bootstrap/dist/css/bootstrap.min.css";
Here, we are using the local Bootstrap file for convenience. As we discussed in Chapter 1, Advanced TypeScript Features, we want to change this to use a CDN source for the production version of this application.
- To tidy up, remove the following line from src/index.tsx and then remove the matching .css file from the disk:
import './index.css'
推薦閱讀
- Linux設(shè)備驅(qū)動(dòng)開(kāi)發(fā)詳解:基于最新的Linux4.0內(nèi)核
- pcDuino開(kāi)發(fā)實(shí)戰(zhàn)
- Linux網(wǎng)絡(luò)管理與配置(第2版)
- 從零開(kāi)始寫(xiě)Linux內(nèi)核:一書(shū)學(xué)透核心原理與實(shí)現(xiàn)
- 異質(zhì)結(jié)原理與器件
- 網(wǎng)絡(luò)操作系統(tǒng)教程:Windows Server 2016管理與配置
- 嵌入式系統(tǒng)及其應(yīng)用(第三版)
- 注冊(cè)表應(yīng)用完全DIY
- ElasticSearch Cookbook
- Cassandra 3.x High Availability(Second Edition)
- Building Telephony Systems With Asterisk
- Advanced Infrastructure Penetration Testing
- Windows Azure實(shí)戰(zhàn)
- Android Telephony原理解析與開(kāi)發(fā)指南
- HarmonyOS應(yīng)用開(kāi)發(fā):快速入門(mén)與項(xiàng)目實(shí)戰(zhàn)