cms icon indicating copy to clipboard operation
cms copied to clipboard

bug: the sidebar re renders when switching between videos

Open alexbennycodes opened this issue 10 months ago • 12 comments

https://github.com/code100x/cms/assets/98402835/7bace462-37f1-4daf-beb2-d439ad8501ce

alexbennycodes avatar Apr 09 '24 06:04 alexbennycodes

🙋 @hkirat

aakash2330 avatar Apr 09 '24 06:04 aakash2330

@aakash2330 if u want u can work on the issue, its simple just move the sidebar component with the get api call to the layout.js file into courseId folder

alexbennycodes avatar Apr 09 '24 06:04 alexbennycodes

I need a little guidance, I added Sidebar in layout.tsx under [...courseId] > layout.tsx, I am getting this error image This error coming under Sidebar.tsx ⨯ src\components\Sidebar.tsx (67:20) @ map ⨯ TypeError: Cannot read properties of undefined (reading 'map') at renderContent (./src/components/Sidebar.tsx:64:25) at Sidebar (./src/components/Sidebar.tsx:204:27) 65 | 66 | const renderContent = (contents: any) => {

67 | return contents.map((content: any) => { | ^ 68 | if (content.children && content.children.length > 0) { 69 | // This is a folder with children 70 | return ( ⨯ src\components\Sidebar.tsx (67:20) @ map ⨯ TypeError: Cannot read properties of undefined (reading 'map') at renderContent (./src/components/Sidebar.tsx:64:25) at Sidebar (./src/components/Sidebar.tsx:204:27) 65 | 66 | const renderContent = (contents: any) => { 67 | return contents.map((content: any) => { | ^ 68 | if (content.children && content.children.length > 0) { 69 | // This is a folder with children 70 | return (

I can't find help on this will need how I can tackle

aakash-a-dev avatar Apr 09 '24 10:04 aakash-a-dev

@aakash-a-dev the session is still in loading phase while the sidebar is being rendered, the response from the server will give unauthorized access, so the contents would be undefined, i guess

alexbennycodes avatar Apr 09 '24 11:04 alexbennycodes

I figured out that layout.tsx doesn't allow data fetching directly so going through documentation probable it can help me out

aakash-a-dev avatar Apr 09 '24 11:04 aakash-a-dev

hey just checked the code out, its not that simple as thought, i might also be working on it, feel free to give a shot

alexbennycodes avatar Apr 09 '24 13:04 alexbennycodes

I Think I'll try it out

krishhh16 avatar Apr 09 '24 13:04 krishhh16

https://github.com/code100x/cms/pull/349

aakash2330 avatar Apr 09 '24 15:04 aakash2330

@aakash2330 this PR does not fix the issue, it will still rerender, the issue i was talking about, is that when a user switches between different videos the sidebar should be fixed and the loader should only come at the place where the video is

alexbennycodes avatar Apr 09 '24 16:04 alexbennycodes

hey just checked the code out, its not that simple as thought, i might also be working on it, feel free to give a shot

I am quite close to the solution just have to call the APIs in the layout I am stuck there, is it possible to work together on this?

aakash-a-dev avatar Apr 09 '24 17:04 aakash-a-dev

@aakash-a-dev I'm done just creating the PR, you can take a look at it.

alexbennycodes avatar Apr 09 '24 18:04 alexbennycodes

@aakash-a-dev I'm done just creating the PR, you can take a look at it.

Okayyy

aakash-a-dev avatar Apr 09 '24 18:04 aakash-a-dev