Skip to content

Commit d07a3e7

Browse files
committed
fix: Props weren't correctly passed into prerender
1 parent e8548a0 commit d07a3e7

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

packages/cli/lib/lib/webpack/prerender.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = async function (env, params) {
2626
);
2727
return '';
2828
}
29-
return (await prerender(app, { ...params, url })).html;
29+
return (await prerender(app, { props: { ...params, url } })).html;
3030
} catch (err) {
3131
let stack = stackTrace.parse(err).filter(s => s.getFileName() === entry)[0];
3232
if (!stack) {

packages/cli/tests/build.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ describe('preact build', () => {
362362
});
363363
});
364364

365-
describe.skip('prerender', () => {
365+
describe('prerender', () => {
366366
prerenderUrlFiles.forEach(prerenderUrls => {
367367
it(`should prerender the routes provided with '${prerenderUrls}'`, async () => {
368368
let dir = await subject('multiple-prerendering');
Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
import { Component } from 'preact';
2-
import { Router } from 'preact-router';
3-
import Home from './routes/home';
4-
import Route66 from './routes/route66';
5-
import Custom from './routes/custom';
2+
import { LocationProvider, Router } from 'preact-iso/router';
3+
import { default as lazy, ErrorBoundary } from 'preact-iso/lazy';
4+
5+
const Home = lazy(() => import('./routes/home.js'));
6+
const Route66 = lazy(() => import('./routes/route66.js'));
7+
const Custom = lazy(() => import('./routes/custom.js'));
68
import './style.css';
79

810
export default class App extends Component {
9-
handleRoute = e => {
10-
this.currentUrl = e.url;
11-
};
12-
1311
render(props) {
1412
return (
15-
<div id="app">
16-
<Router url={props.url} onChange={this.handleRoute} {...props}>
17-
<Home path="/" />
18-
<Route66 path="/route66" />
19-
<Custom path="/custom" {...props} />
20-
</Router>
21-
</div>
13+
<LocationProvider>
14+
<div id="app">
15+
<ErrorBoundary>
16+
<Router url={props.url} {...props}>
17+
<Home path="/" />
18+
<Route66 path="/route66" />
19+
<Custom path="/custom" {...props} />
20+
</Router>
21+
</ErrorBoundary>
22+
</div>
23+
</LocationProvider>
2224
);
2325
}
2426
}

0 commit comments

Comments
 (0)