[BUG] Storybook Navbar Component: TypeError: Cannot read properties of undefined (reading 'data')
Description
I'm getting this error - Cannot read properties of undefined (reading 'data')
The error is being thrown at the following link: https://eddiehubcommunity.github.io/LinkFree/?path=/story/components-navbar-navbar--basic
The error occurs in the Storybook Navbar component and is related to reading the property 'data'

Steps to Reproduce -
Access the page at https://eddiehubcommunity.github.io/LinkFree/?path=/story/components-navbar-navbar--basic
Go to components/navbar/Navbar/Basic
Observe the error being thrown in the Navbar component
Expected Behavior -
The 'data' property should be successfully read without errors and it should display the navbar component

Screenshots
No response
Additional information
A full stack trace of the error is provided below:
TypeError: Cannot read properties of undefined (reading 'data')
at Navbar (https://eddiehubcommunity.github.io/LinkFree/pages-username-stories.317d149d.iframe.bundle.js:1:10794)
at Xh (https://eddiehubcommunity.github.io/LinkFree/475.0ea6cbd8.iframe.bundle.js:517:694469)
at Wk (https://eddiehubcommunity.github.io/LinkFree/475.0ea6cbd8.iframe.bundle.js:517:750962)
at Vk (https://eddiehubcommunity.github.io/LinkFree/475.0ea6cbd8.iframe.bundle.js:517:740158)
at Uk (https://eddiehubcommunity.github.io/LinkFree/475.0ea6cbd8.iframe.bundle.js:517:740089)
at Jk (https://eddiehubcommunity.github.io/LinkFree/475.0ea6cbd8.iframe.bundle.js:517:739958)
at Ok (https://eddiehubcommunity.github.io/LinkFree/475.0ea6cbd8.iframe.bundle.js:517:736814)
at Hk (https://eddiehubcommunity.github.io/LinkFree/475.0ea6cbd8.iframe.bundle.js:517:735369)
at J (https://eddiehubcommunity.github.io/LinkFree/475.0ea6cbd8.iframe.bundle.js:517:789168)
at MessagePort.R (https://eddiehubcommunity.github.io/LinkFree/475.0ea6cbd8.iframe.bundle.js:517:789718)
It's great having you contribute to this project
Welcome to the community :nerd_face:If you would like to continue contributing to open source and would like to do it with an awesome inclusive community, you should join our Discord chat and our GitHub Organisation - we help and encourage each other to contribute to open source little and often 🤓 . Any questions let us know.
I get a different error. Please check you have the latest changes from main and you also have done npm ci.
The error I get is because the component needs to be wrapped in SessionProvider for Storybook
We might need to use a plugin for Storybook to help mock a logged in user https://storybook.js.org/addons/@tomfreudenberg/next-auth-mock

I get a different error. Please check you have the latest changes from main and you also have done npm ci.
The error I get is because the component needs to be wrapped in SessionProvider for Storybook
We might need to use a plugin for Storybook to help mock a logged in user https://storybook.js.org/addons/@tomfreudenberg/next-auth-mock
I followed the above steps and got the same error as you.
So I installed the plugin: next-auth-mock and followed the instructions in the link provided by you
I updated .storybook/main.js and appended the list of addons with @tomfreudenberg/next-auth-mock/storybook -
addons: [
"@storybook/addon-essentials",
"@storybook/addon-a11y",
"@tomfreudenberg/next-auth-mock/storybook",
]
After doing the above the error dissappeared without even wrapping the Navbar component in storybook with SessionProvider
So is this okay or should I still wrap the component?


Also the plugin has provided 6 default set of auth states: session unknown, session loading, admin not authenticated, admin authenticated, user not authenticated, user authenticated.
If I select any one of these two states - session unknown session loading. I will see the Navbar component with the Login button.

If I select any one of these four states - admin not authenticated admin authenticated user not authenticated user authenticated I will see the Navbar component with the Logout button.

I tried to customize these auth states but got a webpack error and couldn't debug it so I think we should create a separate issue and PR for customizing these states. What do you think?
@Saadat-B as you raised this Issue and come up with a solution, I have assigned this to you.
So is this okay or should I still wrap the component?
Oh great, that sounds good if you don't need to wrap it after using the plugin 👍
I tried to customize these auth states but got a webpack error and couldn't debug it so I think we should create a separate issue and PR for customizing these states. What do you think?
Yes, this can come in a separate issue / pull request
Oh great, that sounds good if you don't need to wrap it after using the plugin 👍
Nice then I'll create the PR soon 👍