Description
Using the TableOfContents component in a nextjs layout produces the following error:
## Error Type
Console Error
## Error Message
Encountered a script tag while rendering React component. Scripts inside React components are never executed when rendering on the client. Consider using template tag instead (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template).
at script (<anonymous>:null:null)
at TableOfContents (src/components/table-of-contents-repro.tsx:29:5)
at DocsReproSlugLayout (src/app/docs-repro/[...slug]/layout.tsx:138:35)
## Code Frame
27 |
28 | return (
> 29 | <RenounTableOfContents
| ^
30 | sections={sections}
31 | components={{
32 | Root: (props) => (
Next.js version: 16.2.5 (Turbopack)
Steps to Reproduce
Initial Setup:
git clone git@github.com:noxify/renoun-toc-repro.git
cd renoun-toc-repro
pnpm i
Usage Example:
Interaction:
- Start the dev server (
pnpm dev )
- Browse in desktop mode ( >= 800px ) to: http://localhost:3000/docs-repro/lakeql/introduction/getting-started/
- Change the browser width to 700px or less ( to trigger the mobile mode )
- Change the browser width back to desktop mode
- Open the next dev tool to see the error
Expected Behavior
- The error isn't shown and the script injection is working ( including the additional toc features like highlighting )
Actual Behavior
- it seems that the script injection is working as expected
- the section highlighting isn't shown based on this
Environment
- renoun version:
11.7.1
- Node version:
24.14.1
- Browser (if applicable): Chromium based browser ( currently edge )
- Any other relevant details nextjs 16.2.5
Additional Context
To make it work, I had to copy the renoun toc component ( src/components/toc ).
- removed the inline script injection
- added an
export to TableOfContentsScript
- added the local
TableOfContentsScript component directly into the layout ( src/app/docs/[...slug]/layout.tsx )
The working version can be found here: http://localhost:3000/docs/lakeql/introduction/getting-started/
Here you can
- change the browser width and the error does not occour
- the current section is highlighted
Description
Using the TableOfContents component in a nextjs layout produces the following error:
Steps to Reproduce
Initial Setup:
git clone git@github.com:noxify/renoun-toc-repro.git cd renoun-toc-repro pnpm iUsage Example:
Interaction:
pnpm dev)Expected Behavior
Actual Behavior
Environment
11.7.124.14.1Additional Context
To make it work, I had to copy the renoun toc component (
src/components/toc).exporttoTableOfContentsScriptTableOfContentsScriptcomponent directly into the layout (src/app/docs/[...slug]/layout.tsx)The working version can be found here: http://localhost:3000/docs/lakeql/introduction/getting-started/
Here you can