Skip to content

Commit

Permalink
Update example
Browse files Browse the repository at this point in the history
  • Loading branch information
willybrauner committed Oct 18, 2023
1 parent b69111f commit 85ae7ea
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
6 changes: 2 additions & 4 deletions examples/example-ssr/src/pages/ContactPage.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React, {useState, useRef} from "react"
import { useStack } from "@cher-ami/router";
import {transitionsHelper} from "../helpers/transitionsHelper"
import {transitionsHelper} from "~/helpers/transitionsHelper"

const componentName = "ContactPage"
function ContactPage(props, handleRef) {
const rootRef = useRef(null)
const [n, setN] = useState(0)


useStack({
componentName,
handleRef,
Expand All @@ -15,7 +14,6 @@ function ContactPage(props, handleRef) {
playOut: () => transitionsHelper(rootRef.current, false, { x: -0 }, { x: 50 }),
});


return (
<div className={componentName} ref={rootRef}>
{componentName}
Expand Down
2 changes: 2 additions & 0 deletions examples/example-ssr/vite.scripts.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export default defineConfig(({ command, mode }) => {
chunkFileNames: `[name].js`,
assetFileNames: `[name].[ext]`,
},

external: ["react", "react-dom"],
},
},

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"build:example-ssr": "pnpm --filter ./examples/example-ssr run build",
"size": "size-limit",
"size-why": "size-limit -- --why",
"test": "jest",
"test": "jest && npm run size",
"test:watch": "jest --watch",
"pre-publish": "npm run build && npm run test"
},
Expand Down
5 changes: 2 additions & 3 deletions src/components/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ function Router(props: {
// prettier-ignore
if (isServer) {
if (props.initialStaticProps) {
log("firstRoute > isServer > assign initialStaticProps to newRoute props & set cache",);
log("firstRoute > isServer > assign initialStaticProps to newRoute props & set cache");
Object.assign(newRoute.props, props.initialStaticProps?.props ?? {});
}
}
Expand All @@ -323,8 +323,7 @@ function Router(props: {
// CLIENT > FIRST ROUTE
if (Routers.isFirstRoute) {
if (props.initialStaticProps) {
// assign initial static props to new route props & set cache
log(props.id, "firstRoute > isClient > assign initial static props to new route props & set cache");
log(props.id, "firstRoute > isClient > assign initialStaticProps to newRoute props & set cache");
Object.assign(newRoute.props, props.initialStaticProps?.props ?? {});
cache.set(urlWithoutHash, newRoute.props ?? {});
}
Expand Down
2 changes: 1 addition & 1 deletion tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default defineConfig({
dts: true,
format: ["cjs", "esm"],
name: "@cher-ami/router",
external: ["@wbe/debug", "history", "path-to-regexp", "react"],
external: ["@wbe/debug", "history", "path-to-regexp", "react", "react-dom"],
sourcemap: true,
async onSuccess() {
const process = spawn("npx", ["size-limit"], { shell: true });
Expand Down

0 comments on commit 85ae7ea

Please sign in to comment.