File tree 3 files changed +26
-13
lines changed
packages/react-notion-x/src
3 files changed +26
-13
lines changed Original file line number Diff line number Diff line change @@ -1294,7 +1294,6 @@ svg.notion-page-icon {
1294
1294
float : left;
1295
1295
min-width : var (--notion-max-width );
1296
1296
padding-left : 0 ;
1297
- transition : padding 200ms ease-out;
1298
1297
}
1299
1298
1300
1299
.notion-table-header {
Original file line number Diff line number Diff line change 1
- import * as React from 'react'
1
+ import type * as React from 'react'
2
2
3
3
import { useNotionContext } from '../context'
4
4
import { type CollectionViewProps } from '../types'
@@ -7,6 +7,7 @@ import { CollectionColumnTitle } from './collection-column-title'
7
7
import { CollectionGroup } from './collection-group'
8
8
import { getCollectionGroups } from './collection-utils'
9
9
import { Property } from './property'
10
+ import { useClientStyle } from './react-use'
10
11
11
12
const defaultBlockIds : string [ ] = [ ]
12
13
@@ -72,21 +73,18 @@ function Table({
72
73
} & Omit < CollectionViewProps , 'collectionData' > ) {
73
74
const { recordMap, linkTableTitleProperties } = useNotionContext ( )
74
75
75
- const tableStyle = React . useMemo (
76
- ( ) => ( {
76
+ const tableStyle = useClientStyle (
77
+ {
77
78
width,
78
79
maxWidth : width
79
- } ) ,
80
- [ width ]
80
+ } ,
81
+ { visibility : 'hidden' }
81
82
)
82
83
83
- const tableViewStyle = React . useMemo (
84
- ( ) => ( {
85
- paddingLeft : padding ,
86
- paddingRight : padding
87
- } ) ,
88
- [ padding ]
89
- )
84
+ const tableViewStyle = useClientStyle ( {
85
+ paddingLeft : padding ,
86
+ paddingRight : padding
87
+ } )
90
88
91
89
let properties = [ ]
92
90
Original file line number Diff line number Diff line change @@ -211,3 +211,19 @@ export const useLocalStorage = <T>(
211
211
212
212
return [ state , set , remove ]
213
213
}
214
+
215
+ // Style mismatches between server rendering and client hydration can act
216
+ // unpredictably. Style that depends on the client state should use this hook
217
+ // can prevent the unpredictable behavior. More details here:
218
+ // https://github.com/vercel/next.js/issues/17463
219
+ export const useClientStyle = (
220
+ clientStyle : React . CSSProperties ,
221
+ serverStyle : React . CSSProperties = { }
222
+ ) => {
223
+ const [ isMounted , setIsMounted ] = useState ( false )
224
+ useEffect ( ( ) => {
225
+ setIsMounted ( true )
226
+ } , [ ] )
227
+
228
+ return isMounted ? clientStyle : serverStyle
229
+ }
You can’t perform that action at this time.
0 commit comments