Releases: willybrauner/low-router
Releases · willybrauner/low-router
@wbe/low-router-preact@0.9.1
Patch Changes
- 0569d55: Avoid multiple rerenders on the Stack transition function when the route change.
@wbe/low-router-preact@0.9.0
Minor Changes
- ae073fc: Remove memo wrapper on Router component
@wbe/low-router-preact@0.8.0
Minor Changes
-
90935b1: Patch missing route props on _props copy
reference to #56
In case the route didn't had a specific props object,
_props
wasundefined
, and lastroute.props
of the same route was registered inroute._props
object. To avoid this behavior, we set an empty object onprops.route
if no props exist on the initial route object.
@wbe/low-router-preact@0.7.0
Minor Changes
- dc02cc3: Bump all deps
@wbe/low-router-preact@0.5.0
@wbe/low-router-preact@0.4.0
Minor Changes
- cfb9bf4: Allow augmented Route & RouteContext interfaces
@wbe/low-router-preact@0.3.0
Minor Changes
- 193e647: Prevent hash pathname on server to avoid '/undefined' as matching route
@wbe/low-router-preact@0.2.0
Minor Changes
- cd68512: Internalize preact dependencies in bundle
@wbe/low-router-preact@0.1.0
Minor Changes
-
4e31d18: Low router preact wrapper first release.
Usage example
(check the readme for more information)
main.tsx:
import { render } from "preact" import { createBrowserHistory } from "@wbe/wbe-router" import { Router } from "@wbe/low-router-preact" // Prepare the routes list const routes = [ { name: "home", path: "/", action: () => Home, }, { name: "about", path: "/about", action: () => About, }, ] // Pass the routes list as LowRouter param const router = new LowRouter(routes) // Prepare a browser history const history = createBrowserHistory() // Render the app wrapped by the Router render( <Router router={router} history={history}> <App /> </Router>, document.getElementById("root"), )
App.tsx
import { Link, Stack } from "@wbe/low-router-preact" export default function App() { return ( <div> <nav> <Link to={{ name: "home" }}>{"home"}</Link> <Link to={{ name: "about" }}>{"about"}</Link> </nav> {/* Render current route here */} <Stack /> </div> ) }
Home.tsx
import { useRef, useImperativeHandle } from "preact/hooks" const Home = (props, ref) => { const rootRef = useRef(null) // Each route need to attached name, DOM root, playIn & playOut to the forwarded ref. // The Stack use this forwarded ref in order to control the component. useImperativeHandle( ref, () => ({ name: "Home", root: rootRef.current, playIn: () => customPlayIn(rootRef.current), playOut: () => customPlayOut(rootRef.current), }), [], ) return <div ref={rootRef}>Hello home!</div> } export default forwardRef(Home)
@wbe/low-router@0.9.0
Minor Changes
-
8529535: Matcher returns params even if not matching
const path = "/base/:lang/a-propos/bar" const matcher = createMatcher()
before:
expect(matcher(path, "/base/fr/a-propos/bar/b")).toEqual([false, null, null, null])
after:
expect(matcher(path, "/base/fr/a-propos/bar/b")).toEqual([false, { lang: "fr" }, {}, null])
-
7018e00: nomalize path
Create normalize path helper to get a formatted and constant path format.
path // remove multiples slashes ?.replace(/(https?:\/\/)|(\/)+/g, "$1$2") // remove trailing slash .replace(/\/$/, "") || // add trailing slash if path is empty "/"
normalizePath(path) => string
is available :import { normalizePath } from "@wbe/low-router