remorses/dokz

Unhandled runtime error related to sidebar

josephkmh opened this issue · 6 comments

I wanted to give dokz a try with an existing set of .mdx files I have (a docz project).

I installed dokz in a fresh project using create-dokz-app. I copied all my .mdx files into the pages directory.

The directory tree is very simple:

// in the ./pages directory
index.mdx
rootPageA.mdx
rootPageB.mdx
directoryA // contains multiple .mdx files
directoryB // contains multiple .mdx files

I removed the sidebarOrdering prop from the <DokzProvider> because I just want to use the default navigation.

Unfortunately I am getting an unhandled runtime error that seems to be related to the sidebar navigation:

Unhandled Runtime Error
TypeError: Cannot convert undefined or null to object

Call Stack
Function.keys
<anonymous>
eval
node_modules/dokz/dist/components/SideNav.js (76:0)
eval
node_modules/lodash/_baseOrderBy.js (24:0)
arrayMap
node_modules/lodash/_arrayMap.js (16:0)
eval
node_modules/lodash/_baseOrderBy.js (23:0)
eval
node_modules/lodash/_baseMap.js (17:0)
eval
node_modules/lodash/_createBaseEach.js (24:0)
baseMap
node_modules/lodash/_baseMap.js (16:0)
baseOrderBy
node_modules/lodash/_baseOrderBy.js (22:0)
Object.orderBy [as default]
node_modules/lodash/orderBy.js (44:0)
applySidebarOrdering
node_modules/dokz/dist/components/SideNav.js (75:0)
exports.SideNav
node_modules/dokz/dist/components/SideNav.js (54:0)
renderWithHooks
file:///home/my_user/projects/dokz-test/.next/static/development/dll/dll_f9de5cbc314a1e41f91e.js (15055:18)
mountIndeterminateComponent
/_next/static/development/dll/dll_f9de5cbc314a1e41f91e.js (17734:13)
beginWork
file:///home/my_user/projects/dokz-test/.next/static/development/dll/dll_f9de5cbc314a1e41f91e.js (18848:16)
HTMLUnknownElement.callCallback
/_next/static/development/dll/dll_f9de5cbc314a1e41f91e.js (440:14)
Object.invokeGuardedCallbackDev
file:///home/my_user/projects/dokz-test/.next/static/development/dll/dll_f9de5cbc314a1e41f91e.js (489:16)
invokeGuardedCallback
/_next/static/development/dll/dll_f9de5cbc314a1e41f91e.js (544:31)
beginWork$1
file:///home/my_user/projects/dokz-test/.next/static/development/dll/dll_f9de5cbc314a1e41f91e.js (23455:7)
performUnitOfWork
/_next/static/development/dll/dll_f9de5cbc314a1e41f91e.js (22406:12)
workLoopSync
file:///home/my_user/projects/dokz-test/.next/static/development/dll/dll_f9de5cbc314a1e41f91e.js (22382:22)
performSyncWorkOnRoot
/_next/static/development/dll/dll_f9de5cbc314a1e41f91e.js (22008:9)
scheduleUpdateOnFiber
file:///home/my_user/projects/dokz-test/.next/static/development/dll/dll_f9de5cbc314a1e41f91e.js (21440:7)
updateContainer
/_next/static/development/dll/dll_f9de5cbc314a1e41f91e.js (24625:3)
<unknown>
file:///home/my_user/projects/dokz-test/.next/static/development/dll/dll_f9de5cbc314a1e41f91e.js (25010:7)
unbatchedUpdates
/_next/static/development/dll/dll_f9de5cbc314a1e41f91e.js (22155:12)
legacyRenderSubtreeIntoContainer
file:///home/my_user/projects/dokz-test/.next/static/development/dll/dll_f9de5cbc314a1e41f91e.js (25009:5)
Object.hydrate
/_next/static/development/dll/dll_f9de5cbc314a1e41f91e.js (25075:10)
renderReactElement
../../client/index.js (397:6)
_callee3$
../../client/index.js (523:2)
tryCatch
node_modules/regenerator-runtime/runtime.js (45:14)
Generator.invoke [as _invoke]
node_modules/regenerator-runtime/runtime.js (274:0)
Generator.prototype.<computed> [as next]
node_modules/regenerator-runtime/runtime.js (97:0)
asyncGeneratorStep
node_modules/next/node_modules/@babel/runtime/helpers/asyncToGenerator.js (3:0)
_next
node_modules/next/node_modules/@babel/runtime/helpers/asyncToGenerator.js (25:0)
eval
node_modules/next/node_modules/@babel/runtime/helpers/asyncToGenerator.js (32:0)
new Promise
<anonymous>
eval
node_modules/next/node_modules/@babel/runtime/helpers/asyncToGenerator.js (21:0)
_doRender
webpack-internal:///./node_modules/next/dist/client/index.js (686:20)
doRender
webpack-internal:///./node_modules/next/dist/client/index.js (636:20)
_callee2$
../../client/index.js (305:10)
tryCatch
node_modules/regenerator-runtime/runtime.js (45:14)
Generator.invoke [as _invoke]
node_modules/regenerator-runtime/runtime.js (274:0)
Generator.prototype.<computed> [as next]
node_modules/regenerator-runtime/runtime.js (97:0)
asyncGeneratorStep
node_modules/next/node_modules/@babel/runtime/helpers/asyncToGenerator.js (3:0)
_next
node_modules/next/node_modules/@babel/runtime/helpers/asyncToGenerator.js (25:0)
eval
node_modules/next/node_modules/@babel/runtime/helpers/asyncToGenerator.js (32:0)
new Promise
<anonymous>
eval
node_modules/next/node_modules/@babel/runtime/helpers/asyncToGenerator.js (21:0)
_render
webpack-internal:///./node_modules/next/dist/client/index.js (475:18)

The error persists event when I pass a custom sidebarOrdering prop.

After a bit more experimentation it seems that the error is only coming up when I include sub-directories inside of pages. I guess I assumed this is supported out of the box. Is that not the case?

I will take a look, i changed the sidebar code recently and probably broke subfolders support, i will add a test for that

I added support for collapsable subfolders, now you can actually navigate subfolders
Schermata 2020-06-08 alle 14 49 15

this doesnt seem to be working in the latest version. To repro just npm init dokz-app and create a subfolder with a single file in in "folder"

image

image

image

I fixed again the side bar nested links, try installing latest version

Yep, sidebar is working now, thanks. Although i still get the server html error.