committing comments/documentation on the code

This commit is contained in:
2021-11-16 14:15:22 -06:00
parent 762ae09a0e
commit 80648de7b7
2 changed files with 11 additions and 6 deletions
+9 -4
View File
@@ -1,19 +1,24 @@
/* imports React library */
import React from "react"
import { useEffect, useState } from "react"
/* State is stored directly in the application file */
/* const [customers, assignCustomers] is called a deconstruction array */
export const Repairs = () => {
/* assignCustomers holds an array of the assigned customers a dependancy/subset of customers. i.e. this is your state variable */
const [customers, assignCustomers] = useState([])
useEffect(
() => {
fetch("http://localhost:8088/customers")
.then(res => res.json())
.then(customerAr(customers) customerArray: any
setCustomers(customers) => { }
.then((customers) => {
assignCustomers(customers) }
)
},
},
[]
)
/* JSX, returns whatever HTML code you want rendered to the DOM */
return (
<>
<h1>Honey Rae's Repair Shop</h1>
+2 -2
View File
@@ -1,12 +1,12 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import {Repairs} from './components/Repairs.js'
ReactDOM.render(
<React.StrictMode>
<App />
<Repairs />
</React.StrictMode>,
document.getElementById('root')
);