Skip to content

Instantly share code, notes, and snippets.

View WillyAntunez's full-sized avatar

Willy Antunez WillyAntunez

  • Tegucigalpa, Francisco Morazan, Honduras
View GitHub Profile
@WillyAntunez
WillyAntunez / useHistoryNavigation.ts
Created January 22, 2024 01:54
react-router-dom history navigation custom hook
import { useEffect, useMemo, useRef, useState } from "react"
import { useLocation, useNavigate } from "react-router-dom";
interface HistoryNavigation {
prevPageExists: boolean;
nextPageExists: boolean;
navigateBackward: () => void;
navigateForward: () => void;
currentPageIdx: number;
@WillyAntunez
WillyAntunez / useOutsideAlerter.ts
Last active January 22, 2024 12:17
Outside alerter custom hook
import React, { useEffect } from 'react';
export const useOutsideAlerter = (
ref: React.RefObject<HTMLElement>,
clickOutFunction: (event: Event) => void,
) => {
useEffect(() => {
function handleClickOutside(event: Event) {
const target = event.target as Node;
@WillyAntunez
WillyAntunez / FiltersMenu.jsx
Last active October 9, 2023 15:43
Menú desplegable de filtros para Material UI
/* react */
import { useRef, useState } from 'react';
/* third party libraries */
import { Box, Button, Divider, Grid, Typography } from '@mui/material';
/* custom components */
import { StyledMenu } from './StyledMenu';
import { Small } from './Typography';
/* icons */
import FilterAltIcon from '@mui/icons-material/FilterAlt';
import CloseIcon from '@mui/icons-material/Close';