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 tuono_lib::{ssr, Ssr};
|
||||
|
||||
const MODE: &'static = "prod";
|
||||
|
||||
// MODULE_IMPORTS
|
||||
|
||||
#[tokio::main]
|
||||
|
||||
@@ -21,6 +21,8 @@ export const RouteMatch = ({
|
||||
if (!route.isRoot) {
|
||||
return route.options.getParentRoute().component({
|
||||
children: route.options.component({ data, isLoading }),
|
||||
data,
|
||||
isLoading,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ interface UseServerSidePropsReturn {
|
||||
data: any
|
||||
isLoading: boolean
|
||||
}
|
||||
|
||||
/*
|
||||
* Use the props provided by the SSR and dehydrate the
|
||||
* props for client side usage.
|
||||
@@ -15,6 +16,7 @@ interface UseServerSidePropsReturn {
|
||||
*/
|
||||
export function useServerSideProps(
|
||||
route: Route,
|
||||
// User defined props
|
||||
serverSideProps: any,
|
||||
): UseServerSidePropsReturn {
|
||||
const isFirstRendering = useRef<boolean>(true)
|
||||
@@ -27,8 +29,8 @@ export function useServerSideProps(
|
||||
!isFirstRendering.current,
|
||||
)
|
||||
|
||||
const [data, setData] = useState(
|
||||
serverSideProps || window.__TUONO_SSR_PROPS__.props,
|
||||
const [data, setData] = useState<any>(
|
||||
serverSideProps ?? window.__TUONO_SSR_PROPS__?.props,
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user