Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    react-router-providerpublic

    React Router Provider

    Provide router or location as property to any child component. You can use it as decorator too.

    NPM version

    Install

    npm install react-router-provider

    Support us

    Star this project on GitHub.

    Usage provideRouter

    Decorator

    import React, { Component } from 'react';
    import { provideRouter } from 'react-router-provider';
     
    @provideRouter
    export default class Example extends Component {
      render() {
        const router = this.props.router;
        const isActive = router.isActive();
     
        return (
          <div>{router.isActive}</div>
        );
      }
    }
    ```
     
    ### Function
     
    ```js
    import React, { Component } from 'react';
    import { provideRouter } from 'react-router-provider';
     
    class Example extends Component {
      render() {
        const router = this.props.router;
        const isActive = router.isActive();
     
        return (
          <div>{router.isActive}</div>
        );
      }
    }
     
    export default provideRouter(Example);
    ```
     
    ## Usage provideLocation
     
    ### Decorator
     
    ````js
    import React, { Component } from 'react';
    import { provideLocation } from 'react-router-provider';
     
    @provideLocation
    export default class Example extends Component {
      render() {
        const location = this.props.location;
     
        return (
          <div>{location.query}</div>
        );
      }
    }
    ```
     
    ### Function
     
    ```js
    import React, { Component } from 'react';
    import { provideLocation } from 'react-router-provider';
     
    class Example extends Component {
      render() {
        const location = this.props.location;
     
        return (
          <div>{location.query}</div>
        );
      }
    }
     
    export default provideLocation(Example);
    ```
     
    ## Try our other React components
     
     - Translate your great project [react-translate-maker](https://github.com/CherrySoftware/react-translate-maker) 
     - Forms [react-form-controlled](https://github.com/seeden/react-form-controlled) 
     - Google AdSense via Google Publisher Tag [react-google-publisher-tag](https://github.com/seeden/react-google-publisher-tag) 
     
    # Support us
     
    Star this project on [GitHub][github-url].
     
    ## Credits
     
    [Zlatko Fedor](http://github.com/seeden) 
     
    ## License
     
    The MIT License (MIT)
     
    Copyright (c) 2016 Zlatko Fedor zlatkofedor@cherrysro.com

    install

    npm i react-router-provider

    Downloadslast 7 days

    7

    version

    3.0.2

    license

    MIT

    repository

    github.com

    last publish

    collaborators

    • avatar