Skip to content

Commit

Permalink
fix: Props weren't correctly passed into prerender
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian committed Aug 18, 2022
1 parent 64479e7 commit bd44545
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/cli/lib/lib/webpack/prerender.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = async function (env, params) {
);
return '';
}
return (await prerender(app, { ...params, url })).html;
return (await prerender(app, { props: { ...params, url } })).html;
} catch (err) {
let stack = stackTrace.parse(err).filter(s => s.getFileName() === entry)[0];
if (!stack) {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/tests/build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ describe('preact build', () => {
});
});

describe.skip('prerender', () => {
describe('prerender', () => {
prerenderUrlFiles.forEach(prerenderUrls => {
it(`should prerender the routes provided with '${prerenderUrls}'`, async () => {
let dir = await subject('multiple-prerendering');
Expand Down
32 changes: 17 additions & 15 deletions packages/cli/tests/subjects/multiple-prerendering/index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import { Component } from 'preact';
import { Router } from 'preact-router';
import Home from './routes/home';
import Route66 from './routes/route66';
import Custom from './routes/custom';
import { LocationProvider, Router } from 'preact-iso/router';
import { default as lazy, ErrorBoundary } from 'preact-iso/lazy';

const Home = lazy(() => import('./routes/home.js'));
const Route66 = lazy(() => import('./routes/route66.js'));
const Custom = lazy(() => import('./routes/custom.js'));
import './style.css';

export default class App extends Component {
handleRoute = e => {
this.currentUrl = e.url;
};

render(props) {
return (
<div id="app">
<Router url={props.url} onChange={this.handleRoute} {...props}>
<Home path="/" />
<Route66 path="/route66" />
<Custom path="/custom" {...props} />
</Router>
</div>
<LocationProvider>
<div id="app">
<ErrorBoundary>
<Router url={props.url} {...props}>
<Home path="/" />
<Route66 path="/route66" />
<Custom path="/custom" {...props} />
</Router>
</ErrorBoundary>
</div>
</LocationProvider>
);
}
}

0 comments on commit bd44545

Please sign in to comment.