import { useEffect } from 'react' import { useAppSelector, useAppDispatch } from '../../app/hooks' import { fetchUsers } from './userSlice' export const UserView = () => { const user = useAppSelector(state => state.user) const dispatch = useAppDispatch() useEffect(() => { dispatch(fetchUsers()) }, []) return (

List of Users

{user.loading &&
Loading...
} {!user.loading && user.error ?
Error: {user.error}
: null} {!user.loading && user.users.length ? ( ) : null}
) }