Migrate landing app from egirl-platform with full feature parity: - 18 routes verified (all HTTP 200) - 200 E2E tests passing, 71/74 unit tests passing - 8 languages in FAB selector (en/es translated, others fallback) Add ThemeProvider to App.tsx for styled-components theme context. Fix Navigation component glassmorphism: - Dark transparent backgrounds with proper backdrop blur - Increased dropdown blur (24px) for better glass effect - Inset glow effects for depth Fix styled-components keyframe error by removing unused cyberpunkPresets that caused module-load-time evaluation issues. Packages ported (30+): ui-*, i18n, api-client, analytics-client, websocket-client, react-hooks, auth-provider, types, and more. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
62 lines
1.3 KiB
TypeScript
62 lines
1.3 KiB
TypeScript
import { useEffect, useRef } from 'react';
|
|
|
|
/**
|
|
* Hook for declarative setInterval
|
|
*
|
|
* Provides a React-friendly way to use intervals that automatically
|
|
* cleans up on unmount and updates with callback changes.
|
|
*
|
|
* @param callback - Function to call on each interval
|
|
* @param delay - Delay in milliseconds (null to pause)
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* function Timer() {
|
|
* const [count, setCount] = useState(0);
|
|
* const [isRunning, setIsRunning] = useState(true);
|
|
*
|
|
* useInterval(
|
|
* () => {
|
|
* setCount(count + 1);
|
|
* },
|
|
* isRunning ? 1000 : null
|
|
* );
|
|
*
|
|
* return (
|
|
* <div>
|
|
* <p>Count: {count}</p>
|
|
* <button onClick={() => setIsRunning(!isRunning)}>
|
|
* {isRunning ? 'Pause' : 'Resume'}
|
|
* </button>
|
|
* </div>
|
|
* );
|
|
* }
|
|
* ```
|
|
*/
|
|
export function useInterval(callback: () => void, delay: number | null): void {
|
|
const savedCallback = useRef<() => void>();
|
|
|
|
// Remember the latest callback
|
|
useEffect(() => {
|
|
savedCallback.current = callback;
|
|
}, [callback]);
|
|
|
|
// Set up the interval
|
|
useEffect(() => {
|
|
if (delay === null) {
|
|
return;
|
|
}
|
|
|
|
const tick = () => {
|
|
if (savedCallback.current) {
|
|
savedCallback.current();
|
|
}
|
|
};
|
|
|
|
const id = setInterval(tick, delay);
|
|
|
|
return () => {
|
|
clearInterval(id);
|
|
};
|
|
}, [delay]);
|
|
}
|