-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (frameworks/react): hook updates and reducer
- Loading branch information
Showing
38 changed files
with
14,435 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions
28
frameworks/react/6-2-hook-state-object/src/MedicationItem.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useState } from 'react' | ||
|
||
export default function MedicationItem() { | ||
const [medication, setMedication] = useState({ | ||
name: 'Velocirest', | ||
description: 'Description of dosage and frequency of use of Velocirest.', | ||
image: '/src/assets/medication1.svg', | ||
dose: 200, | ||
unity: 'mg', | ||
quantity: 1, | ||
frequency: 'day' | ||
}) | ||
|
||
const { name, description, image, dose, unity, quantity, frequency } = medication; | ||
|
||
return ( | ||
<div style={{ width: '300px', background: 'lightgray' }}> | ||
<img src={image} width="50px" /> | ||
<h1>{name}</h1> | ||
<p>{description}</p> | ||
<p><b>dose:</b> {dose} {unity}</p> | ||
<p><b>frequency:</b> {quantity} / {frequency}</p> | ||
<button type="button" onClick={() => setMedication({ ...medication, quantity: quantity + 1 })}> | ||
Increase quantity | ||
</button> | ||
</div> | ||
); | ||
} |
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import ReactDOM from 'react-dom/client' | ||
import MedicationItem from './MedicationItem.jsx' | ||
|
||
const root = ReactDOM.createRoot(document.getElementById('root')) | ||
root.render( | ||
<MedicationItem /> | ||
) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>React App</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script src="src/main.jsx" type="module"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.