Skip to content

Commit 1413389

Browse files
enable structural sharing by default in react (#26)
also added `scrollRestoration` and `defaultPreload` options so all templates use the same props
1 parent 69c6e3e commit 1413389

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

templates/react/base/README.md.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ import "./styles.css";
306306
import reportWebVitals from "./reportWebVitals.<%= js %>";
307307
308308
// Create a new router instance
309-
const router = createRouter({ routeTree });
309+
const router = createRouter({ routeTree, defaultPreload: "intent", scrollRestoration: true, defaultStructuralSharing: true });
310310
<% if (typescript) { %>
311311
// Register the router instance for type safety
312312
declare module "@tanstack/react-router" {

templates/react/code-router/src/main.tsx.ejs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const router = createRouter({
5151
routeTree,
5252
defaultPreload: "intent",
5353
scrollRestoration: true,
54+
defaultStructuralSharing: true,
5455
});
5556
<% if (typescript) { %>
5657
declare module "@tanstack/react-router" {

templates/react/file-router/src/main.tsx.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import "./styles.css";
99
import reportWebVitals from "./reportWebVitals.<%= js %>";
1010

1111
// Create a new router instance
12-
const router = createRouter({ routeTree });
12+
const router = createRouter({ routeTree, defaultPreload: "intent", scrollRestoration: true, defaultStructuralSharing: true });
1313

1414
// Register the router instance for type safety
1515
declare module "@tanstack/react-router" {

0 commit comments

Comments
 (0)