How to use the wouter-preact.useRoute function in wouter-preact

To help you get started, we’ve selected a few wouter-preact examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kidqueb / preact-polka-ssr / src / client / components / Route.js View on Github external
export default ({ path, match, store, component, getComponent }) => {
	const useRouteMatch = useRoute(path);
	const [[Component, initialProps], setRoute] = useState([component]);

	// `match` is an array from Switch and NestedRouter
	const [matches, params] = match || useRouteMatch;
	if (!matches) return null;

	// When the component is ready to be rendered kickoff the process of
	// loading async components if needed and processing and `initialProps`
	// That need to be set. 
	useEffect(async () => {
		let c = component, iP = {};

		// If component was undefined we should try grabbing an async component.
		if (!c && getComponent) {
			const m = await getComponent();
			c = m.default || m;

wouter-preact

Minimalist-friendly ~1.5KB router for Preact

Unlicense
Latest version published 22 days ago

Package Health Score

80 / 100
Full package analysis