diff --git a/README.md b/README.md index fd881bf9b..0d5db9eed 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,13 @@ This project includes a `src/components` folder containing several React compone ### Task 1: Project Set Up -- [ ] Create a forked copy of this project. -- [ ] Clone your OWN fork of the repository using your terminal. -- [ ] CD into the project base directory. -- [ ] Download project dependencies by running `npm install`. -- [ ] Start up the app using `npm start`. -- [ ] Optionally run tests using `npm test`. (The app must be running on `http://localhost:1234`) -- [ ] Push commits: `git push origin main`. +- [X] Create a forked copy of this project. +- [X] Clone your OWN fork of the repository using your terminal. +- [X] CD into the project base directory. +- [X] Download project dependencies by running `npm install`. +- [X] Start up the app using `npm start`. +- [X] Optionally run tests using `npm test`. (The app must be running on `http://localhost:1234`) +- [X] Push commits: `git push origin main`. ### Task 2a: Minimum Viable Product @@ -62,4 +62,4 @@ The move by the computer should probably be random if the previous checks turn o ## Submission Format -- [ ] Submit a link to your repo in canvas. +- [X] Submit a link to your repo in canvas. diff --git a/package-lock.json b/package-lock.json index 2320ed32b..511c24b5c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "react-stateful-widgets", "version": "0.0.1", "license": "ISC", "dependencies": { diff --git a/src/components/Counter.js b/src/components/Counter.js index 447a5e849..fc1f74dc5 100644 --- a/src/components/Counter.js +++ b/src/components/Counter.js @@ -1,3 +1,4 @@ + /* COUNTER Instructions @@ -46,38 +47,49 @@ STEP 6: This click handler needs to use 'setCount' to set the 'count' to be zero again. */ -import React from 'react'; /* STEP 0 */ + +import React, { useState } from 'react'; /* STEP 0 */ + + + export default function Counter() { /* STEP 1 */ + const [count, setCount] = useState(0) const increment = () => { + + setCount(count + 1); /* STEP 4 */ }; const decrement = () => { + setCount(count - 1); /* STEP 5 */ }; const reset = () => { + setCount(0); /* STEP 6 */ }; const style = { fontSize: '1.5em', marginBottom: '0.3em', - color: 'royalblue', /* STEP 2 */ + color: count % 2 === 0 ? 'royalblue': 'crimson' /* STEP 2 */ }; return (