Skip to content

Instantly share code, notes, and snippets.

View dzr794's full-sized avatar
🎯
Focusing

David Zapata dzr794

🎯
Focusing
View GitHub Profile
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
@dzr794
dzr794 / todoReducer.js
Created March 11, 2024 22:25
Custom hook: useTodo
export const todoReducer = ( initialState = [], action ) => {
switch ( action.type ) {
case '[TODO] Add Todo':
return [
...initialState,
action.payload
]
@dzr794
dzr794 / useForm.js
Created March 11, 2024 22:24
Custom hook: useForm.js
import { useState } from "react";
export const useForm = ( initialForm = {} ) => {
const [formState, setFormState] = useState( initialForm );
const onInputChange = ({ target }) => {
const { name, value } = target;
@dzr794
dzr794 / useFetch.js
Created March 11, 2024 22:23
Custom hook: useFetch.js
import { useEffect, useState } from "react"
const localCache = {};
export const useFetch = ( url ) => {
const [state, setState] = useState({
data: null,
isLoading: true,
hasError: false,
@dzr794
dzr794 / useCounter.js
Last active March 11, 2024 22:23
Custom hook: useCounter
import { useState } from "react"
export const useCounter = ( initValue = 1) => {
const [counter, setCounter] = useState(initValue);
const increment = ( step = 1 ) => {
setCounter( (current) => current + step);
}
const decrement = ( step = 1 ) => {
@dzr794
dzr794 / getBrowserType.js
Last active February 20, 2024 16:44 — forked from yarinV/script.js
getBrowserType function
function getBrowserType(){
if( navigator.userAgent.indexOf('MSIE 7') > -1 ){
return BrowserString("MSIE 7");
}
if( navigator.userAgent.indexOf('MSIE 8') > -1 ){
return BrowserString("MSIE 8");
}
if( navigator.userAgent.indexOf('MSIE 9') > -1 ){
return BrowserString("MSIE 9");
@dzr794
dzr794 / codigo-inutil.js
Created February 20, 2024 16:40
Test Gist
const holi = 'hola mundo';