mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-25 12:52:47 -07:00
fix: SSR bug on pages with no SSR handler
This commit is contained in:
@@ -22,8 +22,6 @@ use axum::{routing::get, Router};
|
|||||||
use tower_http::services::ServeDir;
|
use tower_http::services::ServeDir;
|
||||||
use tuono_lib::{ssr, Ssr};
|
use tuono_lib::{ssr, Ssr};
|
||||||
|
|
||||||
const MODE: &'static = "prod";
|
|
||||||
|
|
||||||
// MODULE_IMPORTS
|
// MODULE_IMPORTS
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ export const RouteMatch = ({
|
|||||||
if (!route.isRoot) {
|
if (!route.isRoot) {
|
||||||
return route.options.getParentRoute().component({
|
return route.options.getParentRoute().component({
|
||||||
children: route.options.component({ data, isLoading }),
|
children: route.options.component({ data, isLoading }),
|
||||||
|
data,
|
||||||
|
isLoading,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ interface UseServerSidePropsReturn {
|
|||||||
data: any
|
data: any
|
||||||
isLoading: boolean
|
isLoading: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use the props provided by the SSR and dehydrate the
|
* Use the props provided by the SSR and dehydrate the
|
||||||
* props for client side usage.
|
* props for client side usage.
|
||||||
@@ -15,6 +16,7 @@ interface UseServerSidePropsReturn {
|
|||||||
*/
|
*/
|
||||||
export function useServerSideProps(
|
export function useServerSideProps(
|
||||||
route: Route,
|
route: Route,
|
||||||
|
// User defined props
|
||||||
serverSideProps: any,
|
serverSideProps: any,
|
||||||
): UseServerSidePropsReturn {
|
): UseServerSidePropsReturn {
|
||||||
const isFirstRendering = useRef<boolean>(true)
|
const isFirstRendering = useRef<boolean>(true)
|
||||||
@@ -27,8 +29,8 @@ export function useServerSideProps(
|
|||||||
!isFirstRendering.current,
|
!isFirstRendering.current,
|
||||||
)
|
)
|
||||||
|
|
||||||
const [data, setData] = useState(
|
const [data, setData] = useState<any>(
|
||||||
serverSideProps || window.__TUONO_SSR_PROPS__.props,
|
serverSideProps ?? window.__TUONO_SSR_PROPS__?.props,
|
||||||
)
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user