Download src/components/auth/AuthInitializer.jsx from TA-PangandaranAI/PangandaranAI_FE: direct link, hf CLI and curl.
- Browser
- Download file 663 Bytes
-
https://huggingface.co/spaces/TA-PangandaranAI/PangandaranAI_FE/resolve/main/src/components/auth/AuthInitializer.jsx
- Command line
-
hf download hf://spaces/TA-PangandaranAI/PangandaranAI_FE/src/components/auth/AuthInitializer.jsx
-
curl -L -o AuthInitializer.jsx https://huggingface.co/spaces/TA-PangandaranAI/PangandaranAI_FE/resolve/main/src/components/auth/AuthInitializer.jsx
663 Bytes
| 'use client'; | |
| import { useEffect } from 'react'; | |
| import { useDispatch, useSelector } from 'react-redux'; | |
| import { initAuth } from '@/store/authSlice'; | |
| /** | |
| * Invisible auth initializer — dispatches initAuth on mount. | |
| * No UI rendered. Place inside StoreProvider in layout. | |
| */ | |
| export default function AuthInitializer({ children }) { | |
| const dispatch = useDispatch(); | |
| const { initialized } = useSelector((state) => state.auth); | |
| useEffect(() => { | |
| dispatch(initAuth()); | |
| }, [dispatch]); | |
| // Render children immediately — don't block the UI. | |
| // API calls will just fail gracefully if token isn't ready yet. | |
| return children; | |
| } | |