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

shaco-router

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shaco-router

Component to deal with history changes with shaco

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

shaco-router

This is a component for Shaco that allow use the window.history to change the URL on the browser and render diferents components depending of the URL

Example

const TodoContainer = Shaco.ComponentFactory({
  elementName: 'todo-container',
  template: `<content></content>`,
  view: function () {
    /*
     * RouteManager: will allow render one component depending the URL in the browser.
     *
     * the routeIs function receive to params:
     * Fist the pattern to match the URL, Example:
     *    This could be something like:
     *    "/" -> the index
     *    "/tasks"
     *    "/tasks/:id"
     *    ".*" -> the rest
     * The second parameter is and array that will be past to Shaco.createElement. You don't add the state here
     * The State will be passed to all the components inside the router-manager
     * You can use router-manager using JSX like before or using javascript functions, like this:
     *
     */
     
    // With Javascript functions (normal Shaco components)
    // Shaco.createElement('route-manager', null, this.state, {}, () => {
    //   Shaco.createElement('route-selector', null, { pattern: '/', params: ['todo-app', null]} )
    //   Shaco.createElement('route-selector', null, { pattern: '.*', params: ['div', null, {}, "Not found"]} )
    // })

    // With JSX
    return (
      <route-manager state={this.state}>
        <route-selector state={{ pattern: '/', params: ['todo-app', null] }}></route-selector>
        <route-selector state={{ pattern: '.*', params: ['div', null, {}, "Not found"]}}></route-selector>
      </route-manager>
    )
  }
})

Keywords

FAQs

Package last updated on 18 Mar 2016

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