-
+
-
-
+
+
+ {todo
+ .map((v: ITodo) => {
+ return
remove(v.id)} key={v.id}>{v.text}{v.id}
;
+ })}
+
+
- {[...Array(100)]
- .map((v, i) => i)
- .map((v) => {
- return
v
;
- })}
+
);
}
+
+Home.propTypes = {
+ todo: PropTypes.arrayOf(PropTypes.shape({
+ id: PropTypes.number.isRequired,
+ text: PropTypes.string.isRequired
+ }).isRequired).isRequired,
+ add: PropTypes.func.isRequired,
+ remove: PropTypes.func.isRequired
+}
+
+const mapStateToProps = (state: any) => {
+ console.log(state)
+ return {
+ todo: state.todo
+ }
+}
+
+const mapDispatchToProps = (dispatch: any) => ({
+ add: (text: string) => dispatch(addTodo(text)),
+ remove: (id: string | number) => dispatch(removeTodo(id)),
+})
+
+export default connect(mapStateToProps, mapDispatchToProps)(Home);
diff --git a/types/global.d.ts b/types/global.d.ts
new file mode 100644
index 0000000..0af26bb
--- /dev/null
+++ b/types/global.d.ts
@@ -0,0 +1,8 @@
+
+interface IAny{
+ [props: string]: any;
+}
+
+interface IAction extends IAny{
+ type: string
+}