Last active
August 19, 2021 17:36
-
-
Save lucasgomesoficial/16b01414097b2f559d5845def7acbf18 to your computer and use it in GitHub Desktop.
Javascript vanilla pra react
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { FormEvent, useState } from 'react'; | |
| function get () { | |
| const [mes, setMes] = useState(); | |
| const [ano, setAno] = useState(); | |
| function handleDate (e: FormEvent) { | |
| e.preventDefault(); | |
| diaInicial = new Date(ano, mes-1, 1).getDay(); | |
| quantDia = new Date(2021, 08, 0).getDate(); | |
| calendar = []; | |
| for(i = 0; i < diaInicial; i++){ | |
| calendar.push(null); | |
| } | |
| for(i = 1; i <= quantDia; i++){ | |
| calendar.push(i); | |
| } | |
| newCalendar = []; | |
| for(i = 0; i < ) | |
| .slice(1, 3) | |
| console.log(calendar) | |
| } | |
| return ( | |
| <div> | |
| <input | |
| type="number" | |
| placeholder="mês" | |
| onChange={e => setMes(e.target.value)} | |
| value={mes} | |
| /> | |
| <input | |
| type="number" | |
| placeholder="ano" | |
| onChange={e => setAno(e.target.value)} | |
| value={ano} | |
| /> | |
| <button onClick={handleDate}>get Data</button> | |
| </div> | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment