Question about the use of useSession() callback

Why do all of the examples do the const {data:sessionData} for the callback when you can just write
const sessionData = useSession();
const sessionData = useSession();
?
const Home: NextPage = () => {
const {data:sessionData} = useSession();
const printMessage = () => {
console.log(sessionData?.user.firstName);
};
const Home: NextPage = () => {
const {data:sessionData} = useSession();
const printMessage = () => {
console.log(sessionData?.user.firstName);
};
3 Replies
nexxel
nexxel•2y ago
cause then you'll have to do sessionData.data.user.firstName destructuring it is cleaner
jesse
jesseOP•2y ago
Gotcha, thank you for explaining 🙂
HufflePuffDaddy
HufflePuffDaddy•17mo ago
separate question, I've never been able to get any of the actual details out of my user objects for some reason, it only ever has the email and ID. what do I have to do for it to work properly and give me all the information I've set in the prisma schema/ database? thanks
Want results from more Discord servers?
Add your server