This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/routes.rb | |
Rails.application.routes.draw do | |
root 'pages#index' | |
# IMPORTANT # | |
# This `match` must be the *last* route in routes.rb | |
match '*path', to: 'pages#index', via: :all | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/javascript/components/App.js | |
... | |
class App extends React.Component { | |
render() { | |
return ( | |
<div> | |
<Switch> | |
<Route exact path="/" component={Home} /> | |
<Route exact path="/posts" component={Posts} /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/javascript/components/App.js | |
... | |
import { Route, Switch } from 'react-router-dom' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/javascript/packs/index.js | |
... | |
<Router> | |
<Route path="/" component={App} /> | |
</Router>, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/javascript/packs/index.js | |
... | |
document.addEventListener('DOMContentLoaded', () => { | |
ReactDOM.render( | |
<Router> | |
</Router>, | |
document.body.appendChild(document.createElement('div')), | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/javascript/packs/index.js | |
... | |
import { BrowserRouter as Router, Route } from 'react-router-dom' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/javascript/components/App.js | |
import React from 'react' | |
import Home from './Home' | |
import Posts from './Posts' | |
import NewPost from './NewPost' | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/javascript/components/NewPost.js | |
import React from 'react' | |
class NewPost extends React.Component { | |
render() { | |
return ( | |
<div> | |
NewPost page | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/javascript/components/Posts.js | |
import React from 'react' | |
class Posts extends React.Component { | |
render() { | |
return ( | |
<div> | |
Posts page | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/javascript/components/Home.js | |
import React from 'react' | |
class Home extends React.Component { | |
render() { | |
return ( | |
<div> | |
Home page | |
</div> |