Skip to content

Commit 363b85f

Browse files
author
Dimitri POSTOLOV
authoredJul 22, 2024··
[v3] fix RangeError: Maximum call stack size exceeded in findSummary when child.props.children is undefined (#3046)
* aa * aa
1 parent d387dad commit 363b85f

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed
 

‎.changeset/small-ads-glow.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'nextra-theme-blog': patch
3+
'nextra-theme-docs': patch
4+
'nextra': patch
5+
---
6+
7+
add `flex-shrink: 0` for indent in `FileTree` for `<Ident />` and svg icons in `<Folder />`
8+
and `<File />`

‎.changeset/warm-mice-flash.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'nextra-theme-docs': patch
3+
---
4+
5+
fix `RangeError: Maximum call stack size exceeded` in `findSummary` when `child.props.children`
6+
is `undefined`

‎packages/nextra-theme-docs/src/mdx-components.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function Details({
132132
})
133133
return
134134
}
135-
if (child.type !== Details) {
135+
if (child.type !== Details && child.props.children) {
136136
;[summary, child] = findSummary(child.props.children)
137137
}
138138
}

‎packages/nextra/src/client/components/file-tree.tsx

+16-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ function Ident(): ReactElement {
4343
return (
4444
<>
4545
{Array.from({ length }, (_, i) => (
46-
<span className="_w-5" key={i} />
46+
// Text can shrink indent
47+
<span className="_w-5 _shrink-0" key={i} />
4748
))}
4849
</>
4950
)
@@ -69,7 +70,13 @@ const Folder = memo<FolderProps>(
6970
className="_inline-flex _cursor-pointer _items-center _py-1 hover:_opacity-60"
7071
>
7172
<Ident />
72-
<svg width="1em" height="1em" viewBox="0 0 24 24">
73+
<svg
74+
width="1em"
75+
height="1em"
76+
viewBox="0 0 24 24"
77+
// Text can shrink icon
78+
className="_shrink-0"
79+
>
7380
<path
7481
fill="none"
7582
stroke="currentColor"
@@ -105,7 +112,13 @@ const File = memo<FileProps>(({ label, name, active }) => (
105112
>
106113
<span className="_inline-flex _cursor-default _items-center _py-1">
107114
<Ident />
108-
<svg width="1em" height="1em" viewBox="0 0 24 24">
115+
<svg
116+
width="1em"
117+
height="1em"
118+
viewBox="0 0 24 24"
119+
// Text can shrink icon
120+
className="_shrink-0"
121+
>
109122
<path
110123
fill="none"
111124
stroke="currentColor"

0 commit comments

Comments
 (0)
Please sign in to comment.