1
1
import {
2
2
baseUrl as domainTaskBaseUrl ,
3
3
run as domainTaskRun ,
4
- } from "domain-task/main " ;
4
+ } from "domain-task" ;
5
5
import { createMemoryHistory } from "history" ;
6
6
import * as React from "react" ;
7
7
import { renderToStaticMarkup , renderToString } from "react-dom/server" ;
@@ -26,37 +26,36 @@ export function render(callback: RenderCallback, props: RenderFuncProps): void {
26
26
new Error ( `Cannot complete prerendering withing ${ timeout } second` ) ,
27
27
) ;
28
28
} , timeout * 1000 ) ;
29
- domainTaskRun (
30
- ( ) => {
31
- domainTaskBaseUrl ( props . baseUrl ) ;
32
- renderToString ( app ) ;
33
- } ,
34
- /* completion callback */ errorOrNothing => {
35
- clearTimeout ( timeoutTimer ) ;
36
- if ( firstError ) {
37
- return ;
38
- }
39
- if ( errorOrNothing ) {
40
- firstError = errorOrNothing ;
41
- callback ( errorOrNothing ) ;
42
- } else {
43
- const markup = renderToString ( app ) ;
44
29
45
- const htmlProps : HelmetHtmlProps = {
46
- assets : props . assets ,
47
- context,
48
- inlineScripts : props . inlineScripts ,
49
- markup,
50
- } ;
30
+ const completionCallback = errorOrNothing => {
31
+ clearTimeout ( timeoutTimer ) ;
32
+ if ( firstError ) {
33
+ return ;
34
+ }
35
+ if ( errorOrNothing ) {
36
+ firstError = errorOrNothing ;
37
+ callback ( errorOrNothing ) ;
38
+ } else {
39
+ const markup = renderToString ( app ) ;
51
40
52
- const html = renderToStaticMarkup ( < HelmetHtml { ...htmlProps } /> ) ;
41
+ const htmlProps : HelmetHtmlProps = {
42
+ assets : props . assets ,
43
+ context,
44
+ inlineScripts : props . inlineScripts ,
45
+ markup,
46
+ } ;
53
47
54
- callback ( undefined , {
55
- html,
56
- } ) ;
57
- }
58
- } ,
59
- ) ;
48
+ const html = renderToStaticMarkup ( < HelmetHtml { ...htmlProps } /> ) ;
49
+
50
+ callback ( undefined , {
51
+ html,
52
+ } ) ;
53
+ }
54
+ } ;
55
+ domainTaskRun ( ( ) => {
56
+ domainTaskBaseUrl ( props . baseUrl ) ;
57
+ renderToString ( app ) ;
58
+ } , completionCallback ) ;
60
59
} catch ( error ) {
61
60
callback ( error ) ;
62
61
}
0 commit comments