- Install Visual Studio Code, NOTE: This is not Visual Studio
- Install the following addons (Optional but strongly recommended)
- Prettier - Code formatter (This will automatically format your code as you write)
- React Native Tools - Helps with writing some repetitive code
- Create a Chrome Shortcut with no security, follow instructions below:
- Create a folder to have your testing Chrome
- Create a folder within it named temp
- Create a new shortcut with the location
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --user-data-dir="<full path to your temp folder>"
- If it worked you should be able to see the warning:
you are using an unsupported command-line flag: --disable-web-security. Stability and security will suffer.
- Install React Developer Tools
- Make localhost:3000 your homepage for ease of use
- Download and install node.js - Latest Version
- Type
npm
in your terminal to ensure you correctly installed node - Type
npm install
within the root of this repo to install all the dependencies (This will take a while) - Type
npm start
within the root of this repo to start the server and you should have a window open with the front end - [In case of error] If you run into a missing dependency error try
npm install
again thennpm start
if the problem persists manually install the dependency it is asking for.
In case you get an error for a missing dependency just enter in these commands to download the respective dependency:
Package | Command | Site |
---|---|---|
Axios | npm i axios |
https://www.npmjs.com/package/axios |
js Cookie | npm i js-cookie |
https://www.npmjs.com/package/js-cookie |
Create React App | npm i create-react-app |
https://www.npmjs.com/package/create-react-app |
React | npm i react |
https://www.npmjs.com/package/react |
React DOM | npm i react-dom |
https://www.npmjs.com/package/react-dom |
React Scripts | npm i react-scripts |
https://www.npmjs.com/package/react-scripts |
React Router DOM | npm i react-router-dom |
https://www.npmjs.com/package/react-router-dom |
The way useState works is by getting a varaiable and a function to update the variable
// Starting state
const [ total, setTotal ] = useState();
// Starting state With Default Value
const [ page, setPage ] = useState(1);
// Function to Update
setTotal(100);
There are two ways of declaring functions
// without "this" binding
func() {}
// with "this" binding
func = () => {}
the latter, func = () => {} will automatically bind "this" to it. In these functions you can call this, however in the first declaration this will be undefined.
// without "this" binding
func() {
this.setState() // throws error, this is undefined.
}
// with "this" binding
func = () => {
this.setState() // This is fine.
}