Last active
June 23, 2019 14:12
-
-
Save greaveselliott/b464b3adb76f22a40f423d950e0106f2 to your computer and use it in GitHub Desktop.
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
import React, { useRef, useContext } from "react"; | |
import { Store } from "./Store"; | |
import { createNewListItem, deleteNewListItem } from "./Actions"; | |
import "./app.scss"; | |
export default function App() { | |
const { state, dispatch } = useContext(Store); | |
return ( | |
<main className="app"> | |
<h1 className="app__title">To do list</h1> | |
<form className="app__form" onSubmit={onFormSubmit}> | |
<input type="text" className="app__input" ref={input} /> | |
<input | |
type="submit" | |
className="app__input-submit" | |
value="Add to list" | |
/> | |
</form> | |
<ul className="app__list"> | |
{state.list.map((listItem, index) => ( | |
<li className="app__list-item" key={`list-item-${index}`}> | |
{listItem.listItemValue} | |
<button | |
className="app__list-item-delete" | |
onClick={() => onDeleteListItem(listItem.uuid)} | |
> | |
Delete | |
</button> | |
</li> | |
))} | |
</ul> | |
</main> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment