Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

deku-router5

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deku-router5

router5 helpers for Deku

  • 5.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by250%
Maintainers
1
Weekly downloads
 
Created
Source

deku-router5

High-order components and components for Deku when using router5.

This package replaces router5-deku which is deprecated.

Example

Code Demo

Requirements

  • deku >= 0.5.0
  • router5 >= 2.0.0

routerPlugin

It will add your router instance in context.

import { tree, render } from 'deku';
import element from 'virtual-element';
import { routerPlugin } from 'deku-router5';
import App from './App';
import router from './router';

const myApp = tree()
    .use(routerPlugin(router))
    .mount(element(App));

render(myApp, document.getElementById('app'));

RouteNode HOC

routeNode(nodeName): high-order component to wrap a route node component.

Note: your router needs to use router5-listeners plugin.

import element from 'virtual-element';
import { routeNode } from 'deku-router5';
import { UserView, UserList, NotFound } from './components';

const Users = {
    render(props) {
        const { previousRoute, route } from props;

        switch (route.name) {
            case 'users.list':
                return element(UserList);
            case 'users.view':
                return element(UserView);
            default:
                return element(NotFound);
        };
    }
};

export default routeNode('users')(Users);

import element from 'virtual-element';
import { Link } from 'deku-router5';

const Menu = {
    render(props) {
        return element('nav', {}, [
            element(Link, { routeName: 'home', routeOptions: { reload: true } }, 'Home'),
            element(Link, { routeName: 'about', routeOptions: { reload: true } }, 'About')
        ]);
    }
}

export default Menu;

Keywords

FAQs

Package last updated on 19 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc