-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks.js
45 lines (40 loc) · 1.1 KB
/
hooks.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 from "react";
// import { useState } from "react";
// import axios from "axios";
//
// export function useStatefulInputs() {
// const [values, setValues] = useState({});
// const onChange = e =>
// setValues({
// ...values,
// [e.target.name]: e.target.value
// });
// }
//
// ///////////////////////different file
//
// import { useStatefulInputs } from "hooks.js";
//
// const [values, onChange] = useStatefulInputs();
import React from "react";
import { connect } from "react-redux";
import { getListOfAnimals } from "./redux/actions";
class CuteAnimals extends React.Component {
componentDidMount() {
this.props.dispatch(getListOfAnimals());
}
render() {
if (!this.props.myAnimals) {
return;
}
return <h1>Cute Animals</h1>;
}
} // comp ends here
const mapStatetoProps = state => {
return {
myAnimals: state.listAnimals
// we'll come back to this once our global state
// actually has soomething in it
};
};
export default connect(mapStatetoProps)(CuteAnimals);