8000 GitHub - jouyan/quera-7-reza
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

jouyan/quera-7-reza

 
 

Repository files navigation

UseReducer

import React, { useEffect, useReducer, useState } from "react";
import { MessangerLayout } from "./Layout";

const countReducer = (state: any, action: any) => {
  console.log(action);
  switch (action.type) {
    case "increment":
      state = state + action.payload;
      break;
    case "decrement":
      state = state - action.payload;
      break;
    default:
      return state;
  }
  return state;
};

const IntialState = 0;
interface MessangerProps extends React.PropsWithChildren {}
export const Messanger: React.FunctionComponent<Messang
5389
erProps> = (props) => {
  const [state, dispatch] = useReducer(countReducer, IntialState); // flux

  // const [count, setcount] = useState<number>(0);
  const handleIncrement = () =>
    dispatch({
      type: "increment",
      payload: 50,
    });
  const handleDecrement = () =>
    dispatch({
      type: "decrement",
      payload: 100,
    });
  return (
    <>
      <h1>hello {state}</h1>
      <button 
      <button  </button>
    </>
  );
};

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 96.5%
  • HTML 2.4%
  • Other 1.1%
0