Commit cce82cd authored Apr 22, 2021 Verified
1 parent 1e9f459 commit cce82cd Copy full SHA for cce82cd
File tree 5 files changed +40
-20
lines changed
test/integration/router-is-ready/pages
5 files changed +40
-20
lines changed Original file line number Diff line number Diff line change 1
1
import { useRouter } from 'next/router'
2
+ import { useLayoutEffect } from 'react'
2
3
3
4
export default function Page ( props ) {
4
5
const router = useRouter ( )
5
6
6
7
if ( typeof window !== 'undefined' ) {
7
- if ( ! window . isReadyValues ) {
8
- window . isReadyValues = [ ]
9
- }
10
- window . isReadyValues . push ( router . isReady )
8
+ // eslint-disable-next-line react-hooks/rules-of-hooks
9
+ useLayoutEffect ( ( ) => {
10
+ if ( ! window . isReadyValues ) {
11
+ window . isReadyValues = [ ]
12
+ }
13
+ window . isReadyValues . push ( router . isReady )
14
+ } , [ router ] )
11
15
}
12
16
13
17
return (
Original file line number Diff line number Diff line change 1
1
import { useRouter } from 'next/router'
2
+ import { useLayoutEffect } from 'react'
2
3
3
4
export default function Page ( props ) {
4
5
const router = useRouter ( )
5
6
6
7
if ( typeof window !== 'undefined' ) {
7
- if ( ! window . isReadyValues ) {
8
- window . isReadyValues = [ ]
9
- }
10
- window . isReadyValues . push ( router . isReady )
8
+ // eslint-disable-next-line react-hooks/rules-of-hooks
9
+ useLayoutEffect ( ( ) => {
10
+ if ( ! window . isReadyValues ) {
11
+ window . isReadyValues = [ ]
12
+ }
13
+ window . isReadyValues . push ( router . isReady )
14
+ } , [ router ] )
11
15
}
12
16
13
17
return (
Original file line number Diff line number Diff line change 1
1
import { useRouter } from 'next/router'
2
+ import { useLayoutEffect } from 'react'
2
3
3
4
export default function Page ( props ) {
4
5
const router = useRouter ( )
5
6
6
7
if ( typeof window !== 'undefined' ) {
7
- if ( ! window . isReadyValues ) {
8
- window . isReadyValues = [ ]
9
- }
10
- window . isReadyValues . push ( router . isReady )
8
+ // eslint-disable-next-line react-hooks/rules-of-hooks
9
+ useLayoutEffect ( ( ) => {
10
+ if ( ! window . isReadyValues ) {
11
+ window . isReadyValues = [ ]
12
+ }
13
+ window . isReadyValues . push ( router . isReady )
14
+ } , [ router ] )
11
15
}
12
16
13
17
return (
Original file line number Diff line number Diff line change 1
1
import { useRouter } from 'next/router'
2
+ import { useLayoutEffect } from 'react'
2
3
3
4
export default function Page ( props ) {
4
5
const router = useRouter ( )
5
6
6
7
if ( typeof window !== 'undefined' ) {
7
- if ( ! window . isReadyValues ) {
8
- window . isReadyValues = [ ]
9
- }
10
- window . isReadyValues . push ( router . isReady )
8
+ // eslint-disable-next-line react-hooks/rules-of-hooks
9
+ useLayoutEffect ( ( ) => {
10
+ if ( ! window . isReadyValues ) {
11
+ window . isReadyValues = [ ]
12
+ }
13
+ window . isReadyValues . push ( router . isReady )
14
+ } , [ router ] )
11
15
}
12
16
13
17
return (
Original file line number Diff line number Diff line change 1
1
import { useRouter } from 'next/router'
2
+ import { useLayoutEffect } from 'react'
2
3
3
4
export default function Page ( props ) {
4
5
const router = useRouter ( )
5
6
6
7
if ( typeof window !== 'undefined' ) {
7
- if ( ! window . isReadyValues ) {
8
- window . isReadyValues = [ ]
9
- }
10
- window . isReadyValues . push ( router . isReady )
8
+ // eslint-disable-next-line react-hooks/rules-of-hooks
9
+ useLayoutEffect ( ( ) => {
10
+ if ( ! window . isReadyValues ) {
11
+ window . isReadyValues = [ ]
12
+ }
13
+ window . isReadyValues . push ( router . isReady )
14
+ } , [ router ] )
11
15
}
12
16
13
17
return (
You can’t perform that action at this time.
0 commit comments