-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHomePage.js
45 lines (37 loc) · 1.47 KB
/
HomePage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React, { useEffect } from 'react';
import {connect} from 'react-redux';
import Typography from '@material-ui/core/Typography';
import Container from '@material-ui/core/Container';
// Import redux selector and actions
import {doggosActions, doggosSelectors} from "../../redux/doggos";
const HomePage = ({loadDoggos, doggos, errors, resetError, loading}) => {
// useEffect - hook that works as "componentDidMount()" to load some doggo images on mount
useEffect(() => {
// We create initial load of 3 doggo images
if(!doggos) loadDoggos(3);
}, [doggos, loadDoggos]);
// Button handler for loading more images
// const handleLoadMore = (quantity) => loadDoggos(quantity);
return (
<div>
<Container maxWidth={false}>
<Typography variant="h3" align="center">Home page</Typography>
<Typography variant="h6" align="center">⚠ THIS IS WORK IN PROGRESS ⚠</Typography>
</Container>
</div>
);
};
const mapStateToProps = (state, props) => ({
doggos: doggosSelectors.getDoggos(state),
loading: doggosSelectors.getDoggosLoadingErrors(state),
errors: doggosSelectors.getDoggosErrors(state),
});
const mapDispatchToProps = dispatch => ({
loadDoggos: (quantity) => {
dispatch(doggosActions.loadDoggos(quantity))
},
resetError: () => {
dispatch(doggosActions.resetError())
},
});
export default connect(mapStateToProps, mapDispatchToProps)(HomePage);