ello-routes-react
v0.0.3
Published
route manager
Downloads
1
Readme
ello-routes-react
This pacakge provides react routes management for public routes and private routes.
Install
npm install --save ello-routes-react
Usage
import React, { Component } from "react";
import EllocentRouter from "ello-routes-react";
import Login from "..path/to/home/page/component";
import Signup from "..path/to/home/page/component";
import HomePage from "..path/to/home/page/component";
class Example extends Component {
isLoggedIn = () => {
if (condition) return true;
else return false;
};
render() {
return (
<EllocentRouter
PublicRoutes={[
{
path: "/",
page: Login
},
{
path: "/signup",
page: Signup
}
]} // Array of route objects
SecuredRoutes={[{ path: "app/home", page: HomePage }]} // Array of route objects
SecurityLogic={this.isLoggedIn}
CommonData={{
foo: "value",
bar: "value",
...
}} // any data you want to pass to all routes as props
/>
);
}
}
License
MIT © CodeLover12