React JSX Integrating external libraries React Integrating external l ibraries Content 1 The Goals 2 Downloading required packages 3 Importing Libraries 4 Defining Global CSS 5 Modifying Layout 6 Impo[.]
Trang 1Integrating external libraries
Trang 21 The Goals
2 Downloading required packages
3 Importing Libraries
4 Defining Global CSS
5 Modifying Layout
6 Importing Image
7 Using the Public Folder
Trang 31 The Goals
▪ Integrate Bootstrap 5 CSS Framework & Bootstrap icons
Trang 42 Downloading required packages
▪ For Installing bootstrap package, in the terminal type:
npm i bootstrap
▪ For Installing bootstrap icons package, in the terminal type:
npm i bootstrap-icons
Trang 53 Importing Libraries
▪ Import libraries into src\index.js file
Trang 64 Defining Global CSS
▪ Modify src\index.css file
Trang 75 Modifying Layout
▪ Copy & Paste content of “ list.html ” file into src\App.js file.
▪ Fix errors of JSX syntaxes
Trang 86 Importing Image
Trang 107 Using the Public Folder
▪ In the “public\index.html”
Trang 11▪ In JavaScript code, you can use process.env.PUBLIC_URL
for similar purposes
▪ Keep in mind the downsides of this approach
– None of the files in public folder get post-processed or minified.
– Missing files will not be called at compilation time, and will cause 404 errors for your users.
– Result filenames won’t include content hashes so you’ll need to add query arguments or rename them every time they change.
Trang 12When to Use the public Folder
▪ Normally we recommend importing stylesheets, images, and
fonts from JavaScript The public folder is useful as a
workaround for a number of less common cases:
– You need a file with a specific name in the build output, such as
manifest.webmanifest
– You have thousands of images and need to dynamically reference their paths.
– You want to include a small script like pace.js outside of the bundled code.
– Some libraries may be incompatible with webpack and you have no other option but to include it as a <script> tag.
Trang 14▪ Convert HTML into JSX of login.html file
Trang 15THE END