@@ -3,11 +3,12 @@ import type { AstroComponentMetadata, NamedSSRLoadedRendererValue } from 'astro'
33import React from 'react' ;
44import ReactDOM from 'react-dom/server' ;
55import StaticHtml from './static-html.js' ;
6+ import type { RendererContext } from './types.js' ;
67
78const slotName = ( str : string ) => str . trim ( ) . replace ( / [ - _ ] ( [ a - z ] ) / g, ( _ , w ) => w . toUpperCase ( ) ) ;
89const reactTypeof = Symbol . for ( 'react.element' ) ;
910
10- function check ( Component : any , props : Record < string , any > , children : any ) {
11+ function check ( this : RendererContext , Component : any , props : Record < string , any > , children : any ) {
1112 // Note: there are packages that do some unholy things to create "components".
1213 // Checking the $$typeof property catches most of these patterns.
1314 if ( typeof Component === 'object' ) {
@@ -32,12 +33,13 @@ function check(Component: any, props: Record<string, any>, children: any) {
3233 return React . createElement ( 'div' ) ;
3334 }
3435
35- renderToStaticMarkup ( Tester , props , children , { } as any ) ;
36+ renderToStaticMarkup . call ( this , Tester , props , children , { } as any ) ;
3637
3738 return isReactComponent ;
3839}
3940
4041async function renderToStaticMarkup (
42+ this : RendererContext ,
4143 Component : any ,
4244 props : Record < string , any > ,
4345 { default : children , ...slotted } : Record < string , any > ,
@@ -64,7 +66,7 @@ async function renderToStaticMarkup(
6466 }
6567 const componentElement = React . createElement ( Component , newProps ) ;
6668 const vnode = AppEntrypoint
67- ? React . createElement ( AppEntrypoint , null , componentElement )
69+ ? React . createElement ( AppEntrypoint , { locals : this ?. result ?. locals } , componentElement )
6870 : componentElement ;
6971 let html : string ;
7072 if ( metadata ?. hydrate ) {
0 commit comments