refactor: reorganize hooks and add safety checks
fix(api): add validation for listing and seller in bid route feat(telemetry): add userId to MarketTelemetry style(globe): add null check for canvas element chore: add lint:fix script to package.json
This commit is contained in:
1 parent
47c04de6fe
commit
6adc8d96e8
12 files changed
+119
-89
No files matched your search
@@ -93,7 +93,12 @@ export function Globe({
|
||||
},
|
||||
});
|
||||
|
||||
setTimeout(() => (canvasRef.current?.style.opacity = "1"), 0);
|
||||
setTimeout(() => {
|
||||
const el = canvasRef.current;
|
||||
if (el) {
|
||||
el.style.opacity = "1";
|
||||
}
|
||||
}, 0);
|
||||
return () => {
|
||||
globe.destroy();
|
||||
window.removeEventListener("resize", onResize);
|
||||
|
||||
+39
-36
@@ -101,42 +101,7 @@ export const Particles: React.FC<ParticlesProps> = ({
|
||||
const rafID = useRef<number | null>(null);
|
||||
const resizeTimeout = useRef<NodeJS.Timeout | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (canvasRef.current) {
|
||||
context.current = canvasRef.current.getContext("2d");
|
||||
}
|
||||
initCanvas();
|
||||
animate();
|
||||
|
||||
const handleResize = () => {
|
||||
if (resizeTimeout.current) {
|
||||
clearTimeout(resizeTimeout.current);
|
||||
}
|
||||
resizeTimeout.current = setTimeout(() => {
|
||||
initCanvas();
|
||||
}, 200);
|
||||
};
|
||||
|
||||
window.addEventListener("resize", handleResize);
|
||||
|
||||
return () => {
|
||||
if (rafID.current != null) {
|
||||
window.cancelAnimationFrame(rafID.current);
|
||||
}
|
||||
if (resizeTimeout.current) {
|
||||
clearTimeout(resizeTimeout.current);
|
||||
}
|
||||
window.removeEventListener("resize", handleResize);
|
||||
};
|
||||
}, [animate, initCanvas]);
|
||||
|
||||
useEffect(() => {
|
||||
onMouseMove();
|
||||
}, [onMouseMove]);
|
||||
|
||||
useEffect(() => {
|
||||
initCanvas();
|
||||
}, [initCanvas]);
|
||||
|
||||
|
||||
const initCanvas = () => {
|
||||
resizeCanvas();
|
||||
@@ -302,6 +267,44 @@ export const Particles: React.FC<ParticlesProps> = ({
|
||||
rafID.current = window.requestAnimationFrame(animate);
|
||||
};
|
||||
|
||||
// Efeitos devem vir após a declaração das funções referenciadas
|
||||
useEffect(() => {
|
||||
if (canvasRef.current) {
|
||||
context.current = canvasRef.current.getContext("2d");
|
||||
}
|
||||
initCanvas();
|
||||
animate();
|
||||
|
||||
const handleResize = () => {
|
||||
if (resizeTimeout.current) {
|
||||
clearTimeout(resizeTimeout.current);
|
||||
}
|
||||
resizeTimeout.current = setTimeout(() => {
|
||||
initCanvas();
|
||||
}, 200);
|
||||
};
|
||||
|
||||
window.addEventListener("resize", handleResize);
|
||||
|
||||
return () => {
|
||||
if (rafID.current != null) {
|
||||
window.cancelAnimationFrame(rafID.current);
|
||||
}
|
||||
if (resizeTimeout.current) {
|
||||
clearTimeout(resizeTimeout.current);
|
||||
}
|
||||
window.removeEventListener("resize", handleResize);
|
||||
};
|
||||
}, [animate, initCanvas]);
|
||||
|
||||
useEffect(() => {
|
||||
onMouseMove();
|
||||
}, [onMouseMove]);
|
||||
|
||||
useEffect(() => {
|
||||
initCanvas();
|
||||
}, [initCanvas]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn("pointer-events-none", className)}
|
||||
|
||||
Reference in new issue
Block a user