- Migrated from Python pre-commit to NodeJS-native solution - Reorganized documentation structure - Set up Husky + lint-staged for efficient pre-commit hooks - Fixed Dockerfile healthcheck issue - Added comprehensive documentation index
32 lines
643 B
TypeScript
32 lines
643 B
TypeScript
import { useState, useEffect } from 'react';
|
|
|
|
const useUserData = () => {
|
|
const [userData, setUserData] = useState(null);
|
|
const [loading, setLoading] = useState(true);
|
|
const [error, setError] = useState(null);
|
|
|
|
useEffect(() => {
|
|
const fetchUserData = async () => {
|
|
try {
|
|
const response = await fetch('/api/user/profile');
|
|
const data = await response.json();
|
|
setUserData(data);
|
|
} catch (err) {
|
|
setError(err);
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
};
|
|
|
|
fetchUserData();
|
|
}, []);
|
|
|
|
return {
|
|
userData,
|
|
loading,
|
|
error,
|
|
};
|
|
};
|
|
|
|
export default useUserData;
|