Skip to content

Releases: willybrauner/low-router

@wbe/low-router-preact@0.9.1

28 Dec 12:42
fdd8192
Compare
Choose a tag to compare

Patch Changes

  • 0569d55: Avoid multiple rerenders on the Stack transition function when the route change.

@wbe/low-router-preact@0.9.0

18 Oct 09:38
0d54062
Compare
Choose a tag to compare

Minor Changes

  • ae073fc: Remove memo wrapper on Router component

@wbe/low-router-preact@0.8.0

13 Oct 22:32
48911a8
Compare
Choose a tag to compare

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 was undefined, and last route.props of the same route was registered in route._props object. To avoid this behavior, we set an empty object on props.route if no props exist on the initial route object.

@wbe/low-router-preact@0.7.0

13 Oct 22:14
f080af7
Compare
Choose a tag to compare

Minor Changes

@wbe/low-router-preact@0.5.0

12 Oct 17:02
e5016e3
Compare
Choose a tag to compare

Minor Changes

  • ec4a034: getStaticProps params returns RouteContext instead route props (#54)

    before:

      {
        path: "/",
        getStaticProps: async (props, locale) => {}
      }

    after:

      {
        path: "/",
        getStaticProps: async (context, locale) => {}
      }

@wbe/low-router-preact@0.4.0

15 Sep 20:17
433568b
Compare
Choose a tag to compare

Minor Changes

  • cfb9bf4: Allow augmented Route & RouteContext interfaces

@wbe/low-router-preact@0.3.0

07 Sep 21:33
23a2762
Compare
Choose a tag to compare

Minor Changes

  • 193e647: Prevent hash pathname on server to avoid '/undefined' as matching route

@wbe/low-router-preact@0.2.0

07 Sep 20:25
cfadabc
Compare
Choose a tag to compare

Minor Changes

  • cd68512: Internalize preact dependencies in bundle

@wbe/low-router-preact@0.1.0

07 Sep 15:57
be0463d
Compare
Choose a tag to compare

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

16 Aug 15:35
ec503f8
Compare
Choose a tag to compare

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