Skip to content

Instantly share code, notes, and snippets.

@lucasgomesoficial
Last active August 19, 2021 17:36
Show Gist options
  • Select an option

  • Save lucasgomesoficial/16b01414097b2f559d5845def7acbf18 to your computer and use it in GitHub Desktop.

Select an option

Save lucasgomesoficial/16b01414097b2f559d5845def7acbf18 to your computer and use it in GitHub Desktop.
Javascript vanilla pra react
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