Skip to content

fwilkerson/muve-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

muve-router

Simple client side router for muve

Quick start

import muve, {h, interact} from 'muve';
import {createRouterActions, Route, Router, routerModel} from 'muve-router';

const initialModel = Object.assign({}, routerModel);

const {getModel, setModel} = interact(initialModel);

const {handleRouteChanged, setRoute} = createRouterActions(getModel, setModel);

const index = model => (
	<section>
		<a onClick={() => setRoute('/about')}>Go to about page</a>
	</section>
);

const about = model => (
	<section>
		<a onClick={() => setRoute('/')}>Go to index page</a>
	</section>
);

const view = model => (
	<Router model={model} routeChanged={handleRouteChanged}>
		<Route path="/" exact view={index} />
		<Route path="/about" view={about} />
	</Router>
);

muve(view, initialModel, document.getElementById('root'));

About

Simple client side router for muve

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published