toolbox: adds devtoolbox to easily manage debug components

This commit is contained in:
2024-03-16 09:18:16 -06:00
parent 9cbd0a62ca
commit df20a47253
11 changed files with 181 additions and 32 deletions

View File

@@ -1,9 +1,11 @@
import { ReactNode, useCallback, useRef } from 'react'
import { ReactNode, useCallback, useRef } from "react";
export const useRefCallback = <T = ReactNode>() : [T | null, (arg: T) => void] => {
export const useRefCallback = <T = ReactNode>(): [
T | null,
(arg: T) => void,
] => {
const ref = useRef<T | null>(null);
const setRef = useCallback((val: T) => {
console.log(val);
if (ref.current) {
// does something?
}
@@ -12,8 +14,8 @@ export const useRefCallback = <T = ReactNode>() : [T | null, (arg: T) => void] =
// also does something?
}
ref.current = val
}, [])
ref.current = val;
}, []);
return [ref.current, setRef]
}
return [ref.current, setRef];
};