All Projects → GCBenlloch → React Router With Props

GCBenlloch / React Router With Props

Licence: mit
Custom routes for react router dom

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Router With Props

rr-boilerplate
A lightweight React&Redux boilerplate
Stars: ✭ 35 (+52.17%)
Mutual labels:  react-router-v4
Simple React App
Simple base app using react, react-router v4, hot-reload & sass.
Stars: ✭ 263 (+1043.48%)
Mutual labels:  react-router-v4
React Social Network
Simple React Social Network
Stars: ✭ 409 (+1678.26%)
Mutual labels:  react-router-v4
MERN-BUS-APP
This is a MFRP (My first Real Project) assigned to me during my internship at Cognizant. Made with MERN Stack technology.
Stars: ✭ 92 (+300%)
Mutual labels:  react-router-v4
react-chat
react-chat
Stars: ✭ 14 (-39.13%)
Mutual labels:  react-router-v4
React Music
基于React全家桶开发的音乐播放器
Stars: ✭ 281 (+1121.74%)
Mutual labels:  react-router-v4
react-cli
基于 create-react-app 搭建的前端脚手架
Stars: ✭ 18 (-21.74%)
Mutual labels:  react-router-v4
Manager
The Linode Cloud Manager
Stars: ✭ 543 (+2260.87%)
Mutual labels:  react-router-v4
react-ssr-demo
React服务器端渲染Demo
Stars: ✭ 16 (-30.43%)
Mutual labels:  react-router-v4
3yadmin
基于react全家桶+antd构建的专注通用权限控制与表单的后台管理系统模板
Stars: ✭ 381 (+1556.52%)
Mutual labels:  react-router-v4
react-with-mobx-template
project template-react&&mobx
Stars: ✭ 15 (-34.78%)
Mutual labels:  react-router-v4
OverWatchTeams
react+redux+redux-saga+axios
Stars: ✭ 23 (+0%)
Mutual labels:  react-router-v4
React Koa2 Ssr
a Isomorphic framework demo for react server side rendering ( react 同构工程项目骨架,基于create-react-app 和 koa2生成器搭建。)
Stars: ✭ 299 (+1200%)
Mutual labels:  react-router-v4
cerebro-web
Website for Cerebro
Stars: ✭ 21 (-8.7%)
Mutual labels:  react-router-v4
React Blog
react hooks + koa2 + sequelize + mysql 构建的个人博客。具备评论、通知、上传文章等等功能
Stars: ✭ 530 (+2204.35%)
Mutual labels:  react-router-v4
react-universal-starter
React@16, react-router@4, redux and webpack@4 starter project
Stars: ✭ 44 (+91.3%)
Mutual labels:  react-router-v4
React Redux Firebase Authentication
🔥Boilerplate Project for Authentication with Firebase in React and Redux
Stars: ✭ 265 (+1052.17%)
Mutual labels:  react-router-v4
Serverless Stack Demo Client
Source for the demo app client in Serverless-Stack.com
Stars: ✭ 629 (+2634.78%)
Mutual labels:  react-router-v4
Favesound Mobx
🎶 A SoundCloud Client in React + MobX running in production. Live Demo and Source Code to explore React + MobX. Refactored from favesound-redux
Stars: ✭ 532 (+2213.04%)
Mutual labels:  react-router-v4
React Director Admin Template
ReactJS version of Director Responsive Admin Template Free
Stars: ✭ 304 (+1221.74%)
Mutual labels:  react-router-v4

react-router-with-props

Extra routes for react-router-dom.

Install

Install it

npm i -S react-router-with-props

and import it in your file

import { PropsRoute, PublicRoute, PrivateRoute } from 'react-router-with-props';

Route types

  • PropsRoute - Default route to which you can pass props.
  • PublicRoute - It prevents the access to auth users and you can pass props to it.
  • PrivateRoute - It prevents the access to unauth users and you can pass props to it.

Props Route

It's the basic route, but you can pass props to it like to any other component. Any one can access it.

<PropsRoute exact path="/" component={Title} text="Hello world!" />

Public Route

It requires two extra props. | Prop | Type | | |---|---|---| | authed | boolean | If the user is authed or not | | redirectTo | string | route to redirect if necessary |

Only unauthed users can access it.

The next exemple will call the Title component and will pass to it the text prop.

<PublicRoute exact path="/public" authed={false} redirectTo="/admin" component={Title} text="This route is for unauthed users"/>

And this one will call redirect them to '/admin' route.

<PublicRoute exact path="/public" authed={true} redirectTo="/admin" component={Title} text="This route is for unauthed users"/>

Private Route

It requires two extra props. | Prop | Type |---| | ------ | ------ | ------ | | authed | boolean | If the user is authed or not | | redirectTo | string | route to redirect if necessary |

Only authed users can access it.

The next exemple will call the Title component and will pass to it the text prop.

<PrivateRoute exact path="/private" authed={true} redirectTo="/login" component={Title} text="This is a private route"/>

And this one will call redirect them to '/login' route.

<PrivateRoute exact path="/private" authed={false} redirectTo="/login" component={Title} text="This is a private route"/>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].