You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-23Lines changed: 23 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ A router lets you change your view based on the URL in the browser. This allows
10
10
11
11
Solid Router is a universal router for SolidJS - it works whether you're rendering on the client or on the server. It was inspired by and combines paradigms of React Router and the Ember Router. Routes can be defined directly in your app's template using JSX, but you can also pass your route configuration directly as an object. It also supports nested routing, so navigation can change a part of a component, rather than completely replacing it.
12
12
13
-
It supports all of Solid's SSR methods and has Solid's transitions baked in, so use it freely with suspense, resources, and lazy components. Solid Router also allows you to define a load function that loads parallel to the routes ([render-as-you-fetch](https://epicreact.dev/render-as-you-fetch/)).
13
+
It supports all of Solid's SSR methods and has Solid's transitions baked in, so use it freely with suspense, resources, and lazy components. Solid Router also allows you to define a preload function that loads parallel to the routes ([render-as-you-fetch](https://epicreact.dev/render-as-you-fetch/)).
14
14
15
15
-[Getting Started](#getting-started)
16
16
-[Set Up the Router](#set-up-the-router)
@@ -380,25 +380,25 @@ You can nest indefinitely - just remember that only leaf nodes will become their
380
380
</Route>
381
381
```
382
382
383
-
## Load Functions
383
+
## Preload Functions
384
384
385
-
Even with smart caches it is possible that we have waterfalls both with view logic and with lazy loaded code. With load functions, we can instead start fetching the data parallel to loading the route, so we can use the data as soon as possible. The load function is called when the Route is loaded or eagerly when links are hovered.
385
+
Even with smart caches it is possible that we have waterfalls both with view logic and with lazy loaded code. With preload functions, we can instead start fetching the data parallel to loading the route, so we can use the data as soon as possible. The preload function is called when the Route is loaded or eagerly when links are hovered.
386
386
387
-
As its only argument, the load function is passed an object that you can use to access route information:
387
+
As its only argument, the preload function is passed an object that you can use to access route information:
@@ -408,24 +408,24 @@ function loadUser({params, location}) {
408
408
| intent |`"initial", "navigate", "native", "preload"`| Indicates why this function is being called. <ul><li>"initial" - the route is being initially shown (ie page load)</li><li>"native" - navigate originated from the browser (eg back/forward)</li><li>"navigate" - navigate originated from the router (eg call to navigate or anchor clicked)</li><li>"preload" - not navigating, just preloading (eg link hover)</li></ul> |
409
409
410
410
411
-
A common pattern is to export the load function and data wrappers that corresponds to a route in a dedicated `route.data.js` file. This way, the data function can be imported without loading anything else.
411
+
A common pattern is to export the preload function and data wrappers that corresponds to a route in a dedicated `route.data.js` file. This way, the data function can be imported without loading anything else.
The return value of the `load` function is passed to the page component when called at anytime other than `"preload"`, so you can initialize things in there, or alternatively use our new Data APIs:
423
+
The return value of the `preload` function is passed to the page component when called at anytime other than `"preload"` intent, so you can initialize things in there, or alternatively use our new Data APIs:
424
424
425
425
426
426
## Data APIs
427
427
428
-
Keep in mind these are completely optional. To use but showcase the power of our load mechanism.
428
+
Keep in mind these are completely optional. To use but showcase the power of our preload mechanism.
429
429
430
430
### `cache`
431
431
@@ -441,11 +441,11 @@ It is expected that the arguments to the cache function are serializable.
441
441
This cache accomplishes the following:
442
442
443
443
1. It does just deduping on the server for the lifetime of the request.
444
-
2. It does preload cache in the browser which lasts 10 seconds. When a route is preloaded on hover or when load is called when entering a route it will make sure to dedupe calls.
444
+
2. It does preload cache in the browser which lasts 5 seconds. When a route is preloaded on hover or when preload is called when entering a route it will make sure to dedupe calls.
445
445
3. We have a reactive refetch mechanism based on key. So we can tell routes that aren't new to retrigger on action revalidation.
446
446
4. It will serve as a back/forward cache for browser navigation up to 5 mins. Any user based navigation or link click bypasses it. Revalidation or new fetch updates the cache.
447
447
448
-
Using it with load function might look like:
448
+
Using it with preload function might look like:
449
449
450
450
```js
451
451
import { lazy } from"solid-js";
@@ -454,13 +454,13 @@ import { getUser } from ... // the cache function
@@ -770,7 +770,7 @@ The Component for defining Routes:
770
770
| component |`Component`| Component that will be rendered for the matched segment |
771
771
| matchFilters |`MatchFilters`| Additional constraints for matching against the route |
772
772
| children |`JSX.Element`| Nested `<Route>` definitions |
773
-
|load|`RouteLoadFunc`| Function called during preload or when the route is navigated to. |
773
+
|preload|`RoutePreloadFunc`| Function called during preload or when the route is navigated to. |
774
774
775
775
## Router Primitives
776
776
@@ -929,7 +929,7 @@ Related without Outlet component it has to be passed in manually. At which point
929
929
930
930
### `data` functions & `useRouteData`
931
931
932
-
These have been replaced by a load mechanism. This allows link hover preloads (as the load function can be run as much as wanted without worry about reactivity). It support deduping/cache APIs which give more control over how things are cached. It also addresses TS issues with getting the right types in the Component without `typeof` checks.
932
+
These have been replaced by a preload mechanism. This allows link hover preloads (as the preload function can be run as much as wanted without worry about reactivity). It support deduping/cache APIs which give more control over how things are cached. It also addresses TS issues with getting the right types in the Component without `typeof` checks.
933
933
934
934
That being said you can reproduce the old pattern largely by turning off preloads at the router level and then injecting your own Context:
935
935
@@ -939,15 +939,15 @@ import { Route } from "@solidjs/router";
0 commit comments