File tree Expand file tree Collapse file tree 5 files changed +40
-20
lines changed
test/integration/router-is-ready/pages Expand file tree Collapse file tree 5 files changed +40
-20
lines changed Original file line number Diff line number Diff line change 11import { useRouter } from 'next/router'
2+ import { useLayoutEffect } from 'react'
23
34export default function Page ( props ) {
45 const router = useRouter ( )
56
67 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 ] )
1115 }
1216
1317 return (
Original file line number Diff line number Diff line change 11import { useRouter } from 'next/router'
2+ import { useLayoutEffect } from 'react'
23
34export default function Page ( props ) {
45 const router = useRouter ( )
56
67 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 ] )
1115 }
1216
1317 return (
Original file line number Diff line number Diff line change 11import { useRouter } from 'next/router'
2+ import { useLayoutEffect } from 'react'
23
34export default function Page ( props ) {
45 const router = useRouter ( )
56
67 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 ] )
1115 }
1216
1317 return (
Original file line number Diff line number Diff line change 11import { useRouter } from 'next/router'
2+ import { useLayoutEffect } from 'react'
23
34export default function Page ( props ) {
45 const router = useRouter ( )
56
67 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 ] )
1115 }
1216
1317 return (
Original file line number Diff line number Diff line change 11import { useRouter } from 'next/router'
2+ import { useLayoutEffect } from 'react'
23
34export default function Page ( props ) {
45 const router = useRouter ( )
56
67 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 ] )
1115 }
1216
1317 return (
You can’t perform that action at this time.
0 commit comments