Skip to content

Instantly share code, notes, and snippets.

@mtunski
Last active June 18, 2017 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtunski/11a662814b488b97e434b9a4f073cce5 to your computer and use it in GitHub Desktop.
Save mtunski/11a662814b488b97e434b9a4f073cce5 to your computer and use it in GitHub Desktop.
R_on_R => RR v4 + SSR = :(
import React from "react"
import { Route, Switch } from "react-router-dom"
import PageNotFound from "routing/pages/PageNotFound"
import LandingPage from "./pages/LandingPage"
import LoginPage from "./pages/LoginPage"
import SignupPage from "./pages/SignupPage"
const Routes = () =>
<Switch>
<Route exact path="/" component={LandingPage} />
<Route exact path="/login" component={LoginPage} />
<Route exact path="/signup" component={SignupPage} />
<Route component={PageNotFound} />
</Switch>
export default Routes
Rails.application.routes.draw do
root to: "pages#marketing"
get "/platform", to: "pages#platform
get "/platform/*path", to: "pages#platform"
get "*path", to: "pages#marketing"
end
import ReactOnRails from "react-on-rails"
import ServerApp from "./ServerApp"
ReactOnRails.register({
MarketingApp: ServerApp,
})
import React from "react"
import { StaticRouter } from "react-router"
import Routes from "./Routes"
const ServerApp = (
props,
railsContext,
) =>
<StaticRouter
location={railsContext.location}
>
<Routes />
</StaticRouter>
export default ServerApp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment