Coder Social home page Coder Social logo

react-router-rails's Introduction

react-router-rails

Gem Version

React Router for Rails asset pipeline

  • React Router version: 0.11.6

Installation

  1. Add to your Gemfile and install with bundler:
gem 'react-router-rails', '~>0.11.6.1'
bundle install
  1. Require the modified React-Router javascript file in app/assets/javascripts/application.js:
//= require react_router
// OR
//= require react_router.min

Or in app/assets/javascripts/application.js.coffee:

#= require react_router
#OR
#= require react_router.min

#Optional. Gives you the ability to use the view helper in your template
#= require react_router_ujs
  1. Using the view helper:

Define your routes 'MyRoutes' in any javascript file like you would normally do:

var Route = ReactRouter.Route

this.MyRoutes = (
  <Route handler={App}>
    <Route name='home' handler={Home} path='/' />
    ...
  </Route>
)

In the view helper set the name of your routes component

<%= react_router 'MyRoutes' %>

Optionally set the location handler (defaults to HashLocation):

<%= react_router 'MyRoutes', 'HistoryLocation' %>
  1. Using React Router in your javascript :
ReactRouter.run(routes, function (Handler) {
  React.render(<Handler/>, document.body);
});

Or in coffeescript:

ReactRouter.run(routes, (Handler) ->
  React.render <Handler/>, document.body
)

Roadmap

  1. Better handle of production version

Instead of explicit require minified version, we should make it possible to configure that in the environment config files like the react-rails configuration (ex. config.react_router_variant = :production)

  1. Serverside rendering

Use the ReactRouter.run + React.renderToString method to render the markup on the server.

Acknowledgements

This gem is highly inspired and based on React Rails code. Thanks!

React Router by Ryan Florence, Michael Jackson licensed under the MIT license

Copyright Mario Peixoto, released under the MIT license.

react-router-rails's People

Contributors

mariopeixoto avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.