Archived
committing comments/documentation on the code
This commit is contained in:
@@ -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
@@ -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')
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user