1
- import { Box } from '@mui/material'
1
+ /**
2
+ * Use NoSsr on function value.
3
+ * Because in Next.js SSR, the function will be translated to other type
4
+ */
5
+ import { Box , NoSsr } from '@mui/material'
2
6
import type React from 'react'
3
7
4
8
import { useJsonViewerStore } from '../../stores/JsonViewerStore'
@@ -39,7 +43,7 @@ const rb = '}'
39
43
40
44
export const PreFunctionType : React . FC < DataItemProps < Function > > = ( props ) => {
41
45
return (
42
- < >
46
+ < NoSsr >
43
47
< DataTypeLabel dataType = 'function' />
44
48
< Box
45
49
component = 'span' className = 'data-function-start'
@@ -50,42 +54,46 @@ export const PreFunctionType: React.FC<DataItemProps<Function>> = (props) => {
50
54
{ functionName ( props . value ) }
51
55
{ ' ' } { lb }
52
56
</ Box >
53
- </ >
57
+ </ NoSsr >
54
58
)
55
59
}
56
60
57
61
export const PostFunctionType : React . FC < DataItemProps < Function > > = ( ) => {
58
62
return (
59
- < Box component = 'span' className = 'data-function-end' >
60
- { rb }
61
- </ Box >
63
+ < NoSsr >
64
+ < Box component = 'span' className = 'data-function-end' >
65
+ { rb }
66
+ </ Box >
67
+ </ NoSsr >
62
68
)
63
69
}
64
70
65
71
export const FunctionType : React . FC < DataItemProps < Function > > = ( props ) => {
66
72
const functionColor = useJsonViewerStore ( store => store . colorspace . base05 )
67
73
return (
68
- < Box
69
- className = 'data-function'
70
- sx = { {
71
- display : props . inspect ? 'block' : 'inline-block' ,
72
- pl : props . inspect ? 2 : 0 ,
73
- color : functionColor
74
- } }
75
- >
76
- { props . inspect
77
- ? functionBody ( props . value )
78
- : (
79
- < Box component = 'span' className = 'data-function-body'
80
- onClick = { ( ) => props . setInspect ( true ) }
81
- sx = { {
82
- '&:hover' : { cursor : 'pointer' }
83
- } }
84
- >
85
- ...
86
- </ Box >
87
- )
88
- }
89
- </ Box >
74
+ < NoSsr >
75
+ < Box
76
+ className = 'data-function'
77
+ sx = { {
78
+ display : props . inspect ? 'block' : 'inline-block' ,
79
+ pl : props . inspect ? 2 : 0 ,
80
+ color : functionColor
81
+ } }
82
+ >
83
+ { props . inspect
84
+ ? functionBody ( props . value )
85
+ : (
86
+ < Box component = 'span' className = 'data-function-body'
87
+ onClick = { ( ) => props . setInspect ( true ) }
88
+ sx = { {
89
+ '&:hover' : { cursor : 'pointer' }
90
+ } }
91
+ >
92
+ ...
93
+ </ Box >
94
+ )
95
+ }
96
+ </ Box >
97
+ </ NoSsr >
90
98
)
91
99
}
0 commit comments