Created
June 9, 2020 20:20
-
-
Save marshallmurphy/e9e1b79fe19b1710c22d2a749546d97d 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
// App.js | |
// import the useEffect React hook | |
import React, { useEffect } from 'react' | |
// import the useDispatch Redux hook | |
import { useDispatch, useSelector } from 'react-redux' | |
// import our fetchRecipes thunk | |
import { fetchRecipes, recipesSelector } from './slices/recipes' | |
const App = () => { | |
// initialize the redux hook | |
const dispatch = useDispatch() | |
const { recipes, loading, hasErrors } = useSelector(recipesSelector) | |
// dispatch our thunk when component first mounts | |
useEffect(() => { | |
dispatch(fetchRecipes()) | |
}, [dispatch]) | |
return ( | |
<section> | |
<h1>Recipes</h1> | |
</section> | |
) | |
} | |
export default App |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment