فهرست منبع

Add files for first commit

serg1557733 6 ماه پیش
والد
کامیت
d8db66734a
2فایلهای تغییر یافته به همراه22 افزوده شده و 23 حذف شده
  1. 0 23
      src/components/Counter.js
  2. 22 0
      src/components/Show.jsx

+ 0 - 23
src/components/Counter.js

@@ -1,23 +0,0 @@
- import { useDispatch, useSelector } from "react-redux";
- import {inc, dec, rnd} from '../actions'; 
-
-
-
- const Counter = () => {
-
-    const counter = useSelector(state => state.counter);
-    const dispatch = useDispatch();
-
-
-    return (
-            <>
-                <div > {counter} </div>
-                <button onClick={() => dispatch(dec())} > - </button>
-                <button onClick={() => dispatch(inc())} > + </button>
-                <button onClick={() => dispatch(rnd())} > rnd </button>
-            </> 
-        )
-    }
-
-
-export default Counter;

+ 22 - 0
src/components/Show.jsx

@@ -0,0 +1,22 @@
+import reducer from "./reducer";
+import { useReducer } from "react";
+
+const Show = () => {
+
+
+    const [user, dispatch] = useReducer(reducer, {name: 'Ivan', age: 25});
+
+
+
+    return (
+        <>
+         <input onChange={(e) => dispatch({type:'change', payload: e.target.value})} type="text"/>
+            <h1>User name  {user.name}</h1>
+            <h2> User Age {user.age}</h2>
+        </>
+        
+
+    )
+}
+
+export default Show;