@@ -3,10 +3,11 @@ import { Freeze } from 'react-freeze'
33
44import { createBrowserHistory , createHashHistory , History } from 'history'
55
6+ import { WAITING_FIRST_MATCH } from '../../constants/global'
67import { LocationContext } from '../../context/LocationContext'
78import { NavigationContext } from '../../context/NavigationContext'
89import { RouteContext } from '../../context/RouteContext'
9- import { ProHistory , ProInfo } from '../../core/history'
10+ import { ProHistory , ProInfo , ProSubscriber } from '../../core/history'
1011import { MatchRecord , Route } from '../../core/route'
1112import useCreation from '../../hooks/useCreation'
1213import NotFound from '../NotFound'
@@ -15,6 +16,7 @@ export type ErrorInfo = {
1516 type : '404'
1617 error ?: Error
1718}
19+
1820export type ErrorHandler = ( info : ErrorInfo ) => ReactNode | void
1921
2022export type RouterProps = {
@@ -28,6 +30,11 @@ const renderRoutes = (records: MatchRecord[], handleError?: ErrorHandler) => {
2830 const { length } = records
2931
3032 if ( length < 1 ) {
33+ // TODO: insert loading?
34+ if ( WAITING_FIRST_MATCH . value ) {
35+ return null
36+ }
37+
3138 return handleError ?.( { type : '404' } ) || < NotFound />
3239 }
3340
@@ -57,6 +64,7 @@ export const Router = ({
5764 location : history . location ,
5865 records : [ ]
5966 } )
67+
6068 const proHistory = useCreation (
6169 {
6270 factory : ( ) =>
@@ -66,6 +74,8 @@ export const Router = ({
6674 [ basename , history , routes ]
6775 )
6876
77+ console . log ( records )
78+
6979 const children = renderRoutes ( records , onError )
7080
7181 return (
0 commit comments