Skip to content

Conversation

rschristian
Copy link
Member

@rschristian rschristian commented Oct 16, 2024

Still need to figure out the right song & dance for sinon to play nice, but would allow for easier preloading.

import { render } from 'preact';
import { LocationProvider, Router, Route, lazy } from 'preact-iso';

const NotFound = lazy(() => import('./pages/_404.jsx'));

function Home() {
    return (
        <a href="/404" onMouseOver={() => NotFound.preload()}>
            Not Found -- Hover me to preload `NotFound`!
        </a>
    );
}

function App() {
    return (
        <LocationProvider>
            <Router>
                <Route path="/" component={Home} />
                <Route default component={NotFound} />
            </Router>
        </LocationProvider>
    )
}

render(<App />, document.getElementById('app'));

@rschristian rschristian marked this pull request as ready for review October 17, 2024 01:53
@rschristian rschristian merged commit 4c9ed82 into main Oct 17, 2024
1 check passed
@rschristian rschristian deleted the feat/preload-lazy branch October 17, 2024 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants