) {
return (
{columns.map((col) => (
| {col.header} |
))}
{data.map((row) => (
{columns.map((col) => (
|
{col.render ? col.render(row[col.key], row) : String(row[col.key])}
|
))}
))}
)
}
// ============================================================================
// Higher-Order Component Pattern
// ============================================================================
interface WithLoadingProps {
isLoading: boolean
}
function withLoading(
Component: React.ComponentType
,
): React.FC
{
return ({ isLoading, ...props }: WithLoadingProps & P) => {
if (isLoading) {
return
Loading...
}
return
}
}
// Usage
interface UserListProps {
users: User[]
}
const UserList: React.FC = ({ users }) => (
{users.map((user) => (
- {user.name}
))}
)
const UserListWithLoading = withLoading(UserList)
// ============================================================================
// Exports
// ============================================================================
export {
useCounter,
useLoadingState,
useFetch,
useFetchWithReducer,
ContactForm,
FocusInput,
Timer,
}
export type {
ButtonProps,
InputProps,
ListProps,
UseFetchOptions,
UseFetchReturn,
FetchState,
FetchAction,
AuthContextType,
SelectProps,
Column,
TableProps,
}