|
1 |
| -import React, { FunctionComponent } from 'react'; |
| 1 | +import React from 'react'; |
| 2 | +import type { FunctionComponent } from 'react'; |
2 | 3 | import { AppProps } from 'next/app';
|
3 |
| -import { createApp as createAppWithoutSSR, Renderer } from 'reactant'; |
| 4 | +import { createApp as createBaseApp } from 'reactant'; |
| 5 | +import type { Config, Renderer } from 'reactant'; |
4 | 6 | import { AppView } from './appView';
|
5 |
| -import { ServerConfig, ServerApp } from './interfaces'; |
| 7 | +import type { ServerConfig, ServerApp } from './interfaces'; |
6 | 8 |
|
7 | 9 | /**
|
8 | 10 | * create a ServerApp for SSR
|
9 | 11 | */
|
10 | 12 | export const createServerApp = <T, S extends any[], R extends Renderer<S>>(
|
11 | 13 | options: ServerConfig<T, S, R>
|
12 | 14 | ): ServerApp<T, S, R> => {
|
13 |
| - const { |
14 |
| - bootstrap, |
15 |
| - store, |
16 |
| - instance, |
17 |
| - container, |
18 |
| - modules, |
19 |
| - } = createAppWithoutSSR({ |
| 15 | + const { bootstrap, store, instance, container, modules } = createBaseApp({ |
20 | 16 | ...options,
|
21 |
| - // TODO: fix types |
22 |
| - // @ts-ignore |
23 |
| - main: options.main ?? AppView, |
| 17 | + main: options.main ?? (AppView as Config<T, S, R>['main']), |
24 | 18 | render: (element) => element,
|
25 | 19 | });
|
26 | 20 | const AppComponent = (appProps: AppProps) => {
|
27 |
| - return bootstrap((Component: FunctionComponent<AppProps>) => ( |
| 21 | + return (bootstrap as ( |
| 22 | + Component: FunctionComponent<any> |
| 23 | + ) => JSX.Element)((Component: FunctionComponent<AppProps>) => ( |
28 | 24 | <Component {...appProps} />
|
29 | 25 | )) as JSX.Element;
|
30 | 26 | };
|
|
0 commit comments