diff --git a/src/App.js b/src/App.js index 3a28ff3..56a36e2 100644 --- a/src/App.js +++ b/src/App.js @@ -3,6 +3,7 @@ import './App.css'; import FlowerPile from './components/FlowerPile'; import Avatar from './components/Avatar'; import TimeBar from './components/TimeBar'; +import SearchBar from './components/SearchBar'; function App() { const [userData1, setUserData1] = React.useState(null); @@ -16,6 +17,10 @@ function App() { return (
+ - + + { - - React.useEffect(() => { - getUserData(username).then(response => setUserData(response)); - }, []); +const Avatar = ({ userData, position }) => { if (!userData) { return

...WAIT FOR IT

; } - const { avatar_url, login, followers } = userData; + const { avatar_url, login } = userData; return (
diff --git a/src/components/FlowerPile.js b/src/components/FlowerPile.js index fe971cd..7f63a6e 100644 --- a/src/components/FlowerPile.js +++ b/src/components/FlowerPile.js @@ -16,7 +16,7 @@ const FlowerPile = ({ flowerCount, setFlowerCount, position, time}) => { } else { alert('TIME\'S UP BITCH'); } - }, [time]); + }, [time, position, setFlowerCount]); return (
{position === 'left' ? : } diff --git a/src/components/SearchBar.js b/src/components/SearchBar.js index 03e7529..03aa1b8 100644 --- a/src/components/SearchBar.js +++ b/src/components/SearchBar.js @@ -1,4 +1,29 @@ -// import React from 'react'; -// import getUser from '../utils/getUser'; +import React from 'react'; +import { getUserData } from '../utils/getUser'; -// const SearchBar = \ No newline at end of file +const SearchBar = ({position, setUserData}) => { + + const [username, setUsername] = React.useState(''); + + const handleChange = e => setUsername(e.target.value); + + const handleSubmit = e => { + e.preventDefault(); + if (position === 'left') getUserData(username).then(response => setUserData(response)); + if (position === 'right') getUserData(username).then(response => setUserData(response)) + } + + return ( +
+ + +
+ ) +} + +export default SearchBar; \ No newline at end of file diff --git a/src/components/TimeBar.js b/src/components/TimeBar.js index 61ce960..9518abe 100644 --- a/src/components/TimeBar.js +++ b/src/components/TimeBar.js @@ -10,7 +10,7 @@ const TimeBar = ({ userData, time, setTime }) => { if (userData && userData.followers > 10) { setTime(userData.followers); } - }, [userData]); + }, [userData, setTime]); React.useEffect(() => { if (userData) setBarHeight(time/userData.followers*100);