Skip to content

Instantly share code, notes, and snippets.

@Klerith
Last active September 29, 2023 22:35
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save Klerith/0b900641fa2b156021093f658db6279c to your computer and use it in GitHub Desktop.
Save Klerith/0b900641fa2b156021093f658db6279c to your computer and use it in GitHub Desktop.
Hook para el manejo de formularios
import { useState } from 'react';
export const useForm = <T extends Object>( initState: T ) => {
const [state, setState] = useState( initState );
const onChange = ( value: string, field: keyof T ) => {
setState({
...state,
[field]: value
});
}
return {
...state,
form: state,
onChange,
}
}
@SoyRol4ndo
Copy link

Que grande que sos Fernando 🤯... El mejor profesor que he tenido, pero por mucho. Esa voz 😍, esa metodología 😎, ese sentido del humor 😉. Un saludo desde Cuba y el que no conoce a React, a cualquier framework le reza jajajaja

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment