diff --git a/README.md b/README.md index 672f01b..04d071e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Basic React Hooks lunch and learn -## From BERERK [Denver, Colorado's Javascript Pros BERZERK](http://www.BERZERK.io) +## From BERZERK [Denver, Colorado's Javascript Pros BERZERK](http://www.BERZERK.io) This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). diff --git a/src/App.js b/src/App.js index bf8aeef..636d302 100644 --- a/src/App.js +++ b/src/App.js @@ -11,12 +11,14 @@ function App() { const title = useSetTitle(count) - const {data, loading} = useCatApi() + const {data, loading} = useCatApi(count) return (
logo + +

{loading ? 'Loading Cats' : 'This is ameowzing!'}

Edit src/App.js and save to reload.

diff --git a/src/hooks/catApi.js b/src/hooks/catApi.js index 81e1029..0e5ad03 100644 --- a/src/hooks/catApi.js +++ b/src/hooks/catApi.js @@ -1,7 +1,7 @@ import {useEffect, useState} from 'react'; // This is using the cat api -function useCatApi() { +function useCatApi(count) { const [loading, setLoading] = useState(false); const [data, setData] = useState(null) useEffect(()=>{ @@ -16,7 +16,9 @@ function useCatApi() { setLoading(false); } getCats() - },[]) +// !IMPORTANT - deps if no defined it will run on every render, if empty it runs on init only, other wise it watches value +// \/ + },[count]) return {loading, data}; }