
Product
Socket Now Protects the Chrome Extension Ecosystem
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
rwr-react-router
Advanced tools
react-router integration plugin for react_webpack_rails.
This integration makes it possible to render previously created router in rails view.
rwr-react_router
to your Gemfile:gem 'rwr-react_router'
$ npm install --save rwr-react-router
react-router
installed.import RWRReactRouter from 'rwr-react-router';
import { integrationsManager } from 'react-webpack-rails';
integrationsManager.register('react-router', RWRReactRouter.integrationWrapper);
RWRReactRouter.register('MyRouter', MyRouter);
<%= react_router('MyRouter') %>
RWRReactRouter.register
accepts both - react-router instance and function.
When registering function instead of react-router instance, integration will take props (if any were passed to react_router
helper) and will pass them to given function as first argument. This way you can pass them down to router of you choice:
function RouterWithProps(props) {
return (
<Router history={browserHistory}>
<Route path="/with_props" component={App} yourName={props}>
<Route path="about" component={About}/>
<Route path="home" component={Home}/>
</Route>
</Router>
);
}
Props passed to route will be available under props.route.yourName
.
To make router work server-side it need to work on browserHistory. Otherwise, rails don't have access to current route in request. This can be achieved by adding wildcard route to rails routes:
get '/server_side/' => 'pages#server_side'
get '/server_side/*path' => 'pages#server_side'
and setting browserHistory for router:
<Router history={browserHistory}>
<Route path="/server_side" component={App}>
...
</Route>
</Router>
note: react router will analyze whole path so don't forget to add rails path part to it.
With valid setup simply enable server side by passing server_side: true
flag in options:
<%= react_router('MyRouter', { foo: :bar }, server_side: true) %>
note: rwr-react_router automatically handles matching, redirects and routing errors. Redirects and 404's are passed to Rails and handled there so you will be redirect or get 404 page like in normal Rails app.
Found a bug in rwr-react_router? Open an issue on GitHub Issues.
Interested in contributing to rwr-react_router? That's great, and thank you for your interest!
After checking out the repo, run bundle exec rake setup:all
to install every environment dependencies.
To get your contributions accepted, make sure:
bundle exec rake test:all
.The gem is available as open source under the terms of the MIT License.
FAQs
rwr-react_router ====
The npm package rwr-react-router receives a total of 2 weekly downloads. As such, rwr-react-router popularity was classified as not popular.
We found that rwr-react-router demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.