prateekbh / preact-async-route

Async route component for preact-router
MIT License
138 stars 14 forks source link

AsyncRoute renders <undefined></undefined> for 2.0.0 #10

Closed andrewehipp closed 7 years ago

andrewehipp commented 7 years ago

When using preact-async-route@2.0.0 my async route renders <undefined></undefined> on the page.

The chunk loads correctly in the network panel but fails to render correctly. If I switch to normal imports the route renders as expected.

import Router from 'preact-router';
import { createHashHistory } from 'history';
import AsyncRoute from 'preact-async-route';

import Home from './Home';
const About = () => import(/* webpackChunkName: "About" */ './About.js').then(module => module.default);

export default class Routes extends React.Component {
    constructor(props) {
        super(props);
    }

    render() {
        return (
            <Router history={createHashHistory()}>
                <StylePicker path="/" />
                <AsyncRoute path="/home" component={About}/>
            </Router>
        );
    }
}

Reverting to preact-async-route@1.0.3 fixes the issue. Was there a major change that is missing from the docs? Github has the latest release as 1.0.3 but npm has 2.0.0.

prateekbh commented 7 years ago

please try

<AsyncRoute path="/home" getComponent={About}/>
andrewehipp commented 7 years ago

Yep, that fixed it. Thank you