Skip to content

Instantly share code, notes, and snippets.

View latobibor's full-sized avatar
🎯
Focusing

András Tóth latobibor

🎯
Focusing
  • Budapest
View GitHub Profile
@latobibor
latobibor / use-dependency-spy.ts
Last active January 20, 2024 02:07
React dependency spy
/**
* Ever wondered what triggered a rerendering in React?
* Who was the killer? Which dependency got updated?
* This is a very stupid little code that can help you debug the issue.
*/
import { useRef } from 'react';
type DependenciesObject = {
[dependencyName: string]: any;
@latobibor
latobibor / use-abortable-fetch.ts
Last active June 28, 2024 00:25
useAbortableFetch
import { useRef } from 'react';
// wanna send a ton of requests but only needing the last one?
// note: on the backend even aborted requests are going to use resources
export function useAbortableFetch() {
const controllerRef = useRef<AbortController | null>(null);
async function fetchThatAbortsPreviousCall(
input: string | URL | Request,
options?: RequestInit,
@latobibor
latobibor / controller-div.module.css
Created July 4, 2024 22:20
Scrolling in one div moves the other one
/* This is very primitive styling, I kept it like this as style is now not important.
If you change the size make sure the scrollbar is visible as without it nothing will happen.
*/
.controller-div {
background-color: #ddffee;
width: 100px;
height: 200px;
max-height: 100px;
overflow-y: scroll;
border-radius: 15px;