react-router 0.0.0-experimental-e960cf1a → 0.0.0-experimental-bc2c864b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -107,9 +107,7 @@ export interface RouterProps {
107
107
  navigationType?: NavigationType;
108
108
  navigator: Navigator;
109
109
  static?: boolean;
110
- future?: {
111
- v7_relativeSplatPath?: boolean;
112
- };
110
+ future?: Partial<Pick<FutureConfig, "v7_relativeSplatPath">>;
113
111
  }
114
112
  /**
115
113
  * Provides location context for the rest of the app.
@@ -47,7 +47,7 @@ export interface RouteMatch<ParamKey extends string = string, RouteObjectType ex
47
47
  }
48
48
  export interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
49
49
  }
50
- export interface DataRouterContextObject extends NavigationContextObject {
50
+ export interface DataRouterContextObject extends Omit<NavigationContextObject, "future"> {
51
51
  router: Router;
52
52
  staticContext?: StaticHandlerContext;
53
53
  }
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router v0.0.0-experimental-e960cf1a
2
+ * React Router v0.0.0-experimental-bc2c864b
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router v0.0.0-experimental-e960cf1a
2
+ * React Router v0.0.0-experimental-bc2c864b
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -329,7 +329,7 @@ function useRoutesImpl(routes, locationArg, dataRouterState, future) {
329
329
  });
330
330
  {
331
331
  UNSAFE_warning(parentRoute || matches != null, `No routes matched location "${location.pathname}${location.search}${location.hash}" `) ;
332
- UNSAFE_warning(matches == null || matches[matches.length - 1].route.element !== undefined || matches[matches.length - 1].route.Component !== undefined, `Matched leaf route at location "${location.pathname}${location.search}${location.hash}" ` + `does not have an element or Component. This means it will render an <Outlet /> with a ` + `null value by default resulting in an "empty" page.`) ;
332
+ UNSAFE_warning(matches == null || matches[matches.length - 1].route.element !== undefined || matches[matches.length - 1].route.Component !== undefined || matches[matches.length - 1].route.lazy !== undefined, `Matched leaf route at location "${location.pathname}${location.search}${location.hash}" ` + `does not have an element or Component. This means it will render an <Outlet /> with a ` + `null value by default resulting in an "empty" page.`) ;
333
333
  }
334
334
  let renderedMatches = _renderMatches(matches && matches.map(match => Object.assign({}, match, {
335
335
  params: Object.assign({}, parentParams, match.params),
@@ -487,17 +487,24 @@ function _renderMatches(matches, parentMatches = [], dataRouterState = null, fut
487
487
  if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
488
488
  fallbackIndex = i;
489
489
  }
490
- if (match.route.loader && match.route.id && dataRouterState.loaderData[match.route.id] === undefined && (!dataRouterState.errors || dataRouterState.errors[match.route.id] === undefined)) {
491
- // We found the first route without data/errors which means it's loader
492
- // still needs to run. Flag that we need to render a fallback and
493
- // render up until the appropriate fallback
494
- renderFallback = true;
495
- if (fallbackIndex >= 0) {
496
- renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
497
- } else {
498
- renderedMatches = [renderedMatches[0]];
490
+ if (match.route.id) {
491
+ let {
492
+ loaderData,
493
+ errors: _errors
494
+ } = dataRouterState;
495
+ let needsToRunLoader = match.route.loader && loaderData[match.route.id] === undefined && (!_errors || _errors[match.route.id] === undefined);
496
+ if (match.route.lazy || needsToRunLoader) {
497
+ // We found the first route that's not ready to render (waiting on
498
+ // lazy, or has a loader that hasn't run yet). Flag that we need to
499
+ // render a fallback and render up until the appropriate fallback
500
+ renderFallback = true;
501
+ if (fallbackIndex >= 0) {
502
+ renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
503
+ } else {
504
+ renderedMatches = [renderedMatches[0]];
505
+ }
506
+ break;
499
507
  }
500
- break;
501
508
  }
502
509
  }
503
510
  }
@@ -851,7 +858,7 @@ function RouterProvider({
851
858
  // pick up on any render-driven redirects/navigations (useEffect/<Navigate>)
852
859
  React.useLayoutEffect(() => router.subscribe(setState), [router, setState]);
853
860
  React.useEffect(() => {
854
- UNSAFE_warning(fallbackElement == null || !router.future.v7_partialHydration, "`<RouterProvider fallbackElement>` is deprecated when using `v7_partialHydration`") ;
861
+ UNSAFE_warning(fallbackElement == null || !router.future.v7_partialHydration, "`<RouterProvider fallbackElement>` is deprecated when using " + "`v7_partialHydration`, use a `HydrateFallback` component instead") ;
855
862
  // Only log this once on initial mount
856
863
  // eslint-disable-next-line react-hooks/exhaustive-deps
857
864
  }, []);
@@ -876,10 +883,7 @@ function RouterProvider({
876
883
  router,
877
884
  navigator,
878
885
  static: false,
879
- basename,
880
- future: {
881
- v7_relativeSplatPath: router.future.v7_relativeSplatPath
882
- }
886
+ basename
883
887
  }), [router, navigator, basename]);
884
888
  // The fragment and {null} here are important! We need them to keep React 18's
885
889
  // useId happy when we are server-rendering since we may have a <script> here
@@ -895,8 +899,11 @@ function RouterProvider({
895
899
  basename: basename,
896
900
  location: state.location,
897
901
  navigationType: state.historyAction,
898
- navigator: navigator
899
- }, state.initialized ? /*#__PURE__*/React.createElement(DataRoutes, {
902
+ navigator: navigator,
903
+ future: {
904
+ v7_relativeSplatPath: router.future.v7_relativeSplatPath
905
+ }
906
+ }, state.initialized || router.future.v7_partialHydration ? /*#__PURE__*/React.createElement(DataRoutes, {
900
907
  routes: router.routes,
901
908
  future: router.future,
902
909
  state: state