Creating Admin Portal Project in React
From Logic Wiki
Contents
Starting a project
Setting Up The Environment
- install node
- install create-react-app
npm i -g create-react-app
install VS Code
- install VS Code
- install VS Code snippets - Click Extensions icon on the left sidebar and search and install
- Simple React Snippets by Burke Holland
- Prettier by Esben Petersen
- Set Format on Save
in VS Code go to File / Preferences / Settings and add the line below in UserSettings section
"editor.formatOnSave":true
Create React App
Go to the project folder
npx create-react-app adminportal
cd adminportal
adminportal is lowercase because [Create React App] doesn't like capitals
Install Bootstrap
npm i bootstrap@4.1.1
go to ./src/index.js and add this line
import 'bootstrap/dist/css/bootstrap.css';
Installing FontAwesome Icons
npm i --save @fortawesome/fontawesome-svg-core npm i --save @fortawesome/free-solid-svg-icons npm i --save @fortawesome/react-fontawesome
Then in your app, import and add an icon to the Library:
App.js
import { library } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faIgloo } from '@fortawesome/free-solid-svg-icons'
library.add(faIgloo)
Lastly, use the component and icon in your JSX:
import React from 'react'
import { faSearch } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
export const Food = () => (
<FontAwesomeIcon icon={faSearch} />
)
https://scotch.io/tutorials/using-font-awesome-5-with-react
Install nodemon
it restarts the application when file contents changes.
npm install --save-dev nodemon
Usage
npx nodemon index.js