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 { useState } from "react"; | |
const useCounter = ( initialState = 1 ) => { | |
const [ counter, setCounter ] = useState( initialState ); | |
const increment = () => { | |
setCounter( counter + 1 ); | |
} |
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 { useEffect, useRef, useState } from "react"; | |
const useFetch = (url) => { | |
const isMounted = useRef(true); //mantienes la referencia a la variable. | |
const [ state, setState ] = useState({ | |
data: null, | |
loading: true, |
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 { useState } from "react"; | |
const useForm = ( initialState = {} ) => { | |
const [ values, setValues ] = useState(initialState); | |
// Agregar Valores al Formulario: | |
const handleInputChanges = ( { target } ) => { | |
setValues({ |
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 { useReducer, useEffect } from 'react'; | |
interface AuthState { | |
validando: boolean; | |
token: null | string; | |
username: string; | |
nombre: string; | |
} | |
type LoginPayload = { |