Advertisement
mierzvoj

Untitled

May 25th, 2022
805
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, {ChangeEvent, FormEvent, useEffect, useReducer, useState} from 'react';
  2. import logo from './logo.svg';
  3. import './App.css';
  4. import {Simulate} from "react-dom/test-utils";
  5. import submit = Simulate.submit;
  6.  
  7. const ACTIONS ={
  8.     divide:
  9. }
  10.  
  11.  
  12. function reducer(number, action){
  13.  
  14. }
  15. export default function App() {
  16.     const[state, dispatch] = useReducer(reducer, []);
  17.     const [value, setValue] = useState<number>(0);
  18.  
  19.     useEffect(() => {
  20.         console.log(value)
  21.     }, [value])
  22.  
  23.     function handleSubmit(e: number){
  24.       dispatch({})
  25.     }
  26.  
  27.     return (
  28.  
  29.             <form onSubmit ={(e: FormEvent<HTMLFormElement>) => handleSubmit(parseInt(e))}>
  30.                 <input type="text" value={value}
  31.                        onChange={(e: ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) => setValue(parseInt(e.target.value))}/>
  32.                 <p>{ value }</p>
  33.                 <button type="submit">Caculate</button>
  34.             </form>
  35.  
  36.  
  37.     );
  38.  
  39. }
  40.  
  41.  
Advertisement
RAW Paste Data Copied
Advertisement