#cannot use `useLoaderData`

1 messages · Page 1 of 1 (latest)

wispy dagger
#
TypeError: Cannot read properties of undefined (reading '2')
    at we (https://esm.sh/v126/[email protected]/X-ZS9yZWFjdCxyZWFjdC1kb20/node/react-router.mjs:4:6226)
    at Object.Docs (src/pages/docs/:parent/:id?.jsx:6:14)
    at k (https://esm.sh/v126/[email protected]/node/preact-render-to-string.bundle.mjs:1:2444)
    at k (https://esm.sh/v126/[email protected]/node/preact-render-to-string.bundle.mjs:1:2528)
    at k (https://esm.sh/v126/[email protected]/node/preact-render-to-string.bundle.mjs:1:2528)
    at k (https://esm.sh/v126/[email protected]/node/preact-render-to-string.bundle.mjs:1:2528)
    at k (https://esm.sh/v126/[email protected]/node/preact-render-to-string.bundle.mjs:1:2528)
    at k (https://esm.sh/v126/[email protected]/node/preact-render-to-string.bundle.mjs:1:2528)
    at k (https://esm.sh/v126/[email protected]/node/preact-render-to-string.bundle.mjs:1:2528)
    at k (https://esm.sh/v126/[email protected]/node/preact-render-to-string.bundle.mjs:1:2528)
___________________

The we function is being referred to the useLoaderData(), since the code is minifed (using url imports) so the naming is also minfied.

#
import {useLoaderData} from 'react-router-dom';

import Body from '../../../components/docs/Body';

export default function Docs() {
        console.log(useLoaderData());
  return (
    <Body parent={params.parent} child={params.id || ""} />
  )
}

Route object:

{
    path: "/docs/:page/:id?",
        loader: () => {
                return {hello: "world"};
        },
    element: <DocsPage />,
    errorElement: <ErrorBoundary />,
  },
sand linden
#

looks correct to me, but if you could reproduce it not using minified code that would be great

wispy dagger
#

Ive tried using react router dom from npm, but it wont work alongside the other esm based modules, as it cant require esm modules. So the only option left is to debug the minified code. Hopefully I've found a string (console log warning/error in the minified code) and I should be able to trace it back to the original file.

#

@sand linden ^^

#

If you have any other ideas, feel free to tell me