diff --git a/src/App.js b/src/App.js
index bcb5892..3a00978 100644
--- a/src/App.js
+++ b/src/App.js
@@ -5,9 +5,13 @@ import { Switch, Route, BrowserRouter, Link } from 'react-router-dom'
import FinishedGhibliMovies from './finished/GhibliMovies';
import FinishedTwoButtons from './finished/TwoButtons'
import FinishedKittenVotes from './finished/KittenVotes';
+import FinishedStatefulButton from './finished/StatefulButton';
+
import TwoButtons from './toDo/TwoButtons';
import GhibliMovies from './toDo/GhibliMovies';
import KittenVotes from './toDo/KittenVotes';
+import StatefulButton from './toDo/StatefulButton';
+
import MainPage from './MainPage';
@@ -25,6 +29,8 @@ function App() {
useState
useEffect
useContext
+ useStateButton
+
setShowFinished(!showFinished)}>
Show finished components
@@ -54,6 +60,11 @@ function App() {
path="/useContext"
component={showFinished ? FinishedTwoButtons : TwoButtons}
/>
+
diff --git a/src/finished/StatefulButton.jsx b/src/finished/StatefulButton.jsx
new file mode 100644
index 0000000..e69de29
diff --git a/src/toDo/GhibliMovies.jsx b/src/toDo/GhibliMovies.jsx
index cc4a652..0eaf411 100644
--- a/src/toDo/GhibliMovies.jsx
+++ b/src/toDo/GhibliMovies.jsx
@@ -18,16 +18,55 @@ import { MovieTable } from '../helperComponents';
*/
-
const GhibliMovies = () => {
const [movies, setMovies] = useState([]);
-
+ useEffect(() => {
+ GhibliApiService.getMovieList().then((data) => {
+ setMovies(data);
+
+ })
+ }, [])
return (
<>
useEffect
+ >
+ )
+}
+
+const usePictures = () => {
+ const [pics, setPics] = useState([]);
+ const [count, setCount] = useState(0);
+ const [countInTimeout, setCountInTimeout] = useState(0);
+ useEffect(() => {
+ const timer = setTimeout(() => {
+ console.log('This will run after 5 second!')
+ setCountInTimeout(count); // count is 0 here
+ GhibliApiService.getMovieList().then((data)=>{
+ setPics(data)
+
+ }, 5000);
+ setCount(5);
+ console.log("count: " +count)
+ console.log("setTimeout count: " + countInTimeout)
+ return () => clearTimeout(timer);
+
+ })
+ },[])
+ return pics
+}
+const GhiblicustomHook = () => {
+
+
+ return (
+ <>
+ useMovies - Custom Hook
+
+
+
>
)
-};
+}
+
-export default GhibliMovies;
+export default GhiblicustomHook
diff --git a/src/toDo/KittenVotes.jsx b/src/toDo/KittenVotes.jsx
index 94d1cff..8f01f23 100644
--- a/src/toDo/KittenVotes.jsx
+++ b/src/toDo/KittenVotes.jsx
@@ -12,13 +12,14 @@ import { Card, Button, CardGrid} from '@edx/paragon';
*/
const KittenVotes = () => {
-
+ const [meow, meowClicks] = useState(0);
+ const [princess, princessClicks] = useState(0);
return (
<>
useState
- Meowser was clicked 0 times!
- Princess Purr was clicked 0 times!
+ Meowser was clicked {meow} times!
+ Princess Purr was clicked {princess} times!
{/* Display vote counts here */}
@@ -30,6 +31,7 @@ const KittenVotes = () => {
Vote for Meowser!
{/* Meowser button here */}
+
@@ -40,6 +42,8 @@ const KittenVotes = () => {
Vote for Princess Purr!
{/* Princess Purr button here */}
+
+
diff --git a/src/toDo/StatefulButton.jsx b/src/toDo/StatefulButton.jsx
index bf4b46f..c09ffd8 100644
--- a/src/toDo/StatefulButton.jsx
+++ b/src/toDo/StatefulButton.jsx
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
-import {Button} from '@edx/paragon';
+import {Button, TextArea} from '@edx/paragon';
/* INSTRUCTIONS for useState
Using the `useState` hook, create a button that increments a counter and displays the current button count
@@ -10,10 +10,22 @@ import {Button} from '@edx/paragon';
const StatefulButton = () => {
+ const [increment, setIncrement] = useState(0);
return (
<>
useState
{/* PUT BUTTON HERE */}
+
+
+ {increment}
+
+
+
+
+
+
+
+
>
)
};
diff --git a/src/toDo/TwoButtons.jsx b/src/toDo/TwoButtons.jsx
index 96994b9..17ea7e6 100644
--- a/src/toDo/TwoButtons.jsx
+++ b/src/toDo/TwoButtons.jsx
@@ -9,21 +9,56 @@ import { Button } from '@edx/paragon'
- ClickReport
- should display the click count
*/
+const themes = {
+
+ light:{
+
+ color: 'purple',
+ backgroundColor: 'green',
+ },
+ dark: {
+ color: 'green',
+ backgroundColor: 'yellow',
+ }
+
+};
const ClickContext = React.createContext();
+const ThemeContext = React.createContext();
const ClickContextProvider = ({ children }) => {
const [count, setCount] = useState(0)
return {children}
}
-const ContextButton = () => {
+const ThemeContextProvider = ({ children}) => {
+
+ return {children}
+
+}
+
+const ContextButton = ({ text }) => {
+ const [aclick, setAclick] = useContext(ClickContext)
+ return
}
const ClickReport = () => {
+ const [display] = useContext(ClickContext)
+
+ return The count is {display}
}
+const ClearButton = ({text, className}) => {
+ const [clear, setClear] = useContext(ClickContext)
+ return
+}
+const ThemedButton = ({text}) => {
+ const color = useContext(ThemeContext)
+ return
+}
+
+
const TwoButtons = () => {
return (
@@ -31,7 +66,22 @@ const TwoButtons = () => {
useContext
{/* Put Buttons and ClickReport here */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{/* What happens if you put buttons here? */}
>
)