ShakaCode | ShakaCode Blog | Rails On Maui Blog | Rails | ReactJs | JavaScript | Webpack | Productivity |

Having trouble implementing react router


#1

Hi, I’m new to rails and react on rails. I am trying to make a minimal react on rails app with some routing, but I can’t seem to implement routing at all. I tried studying https://github.com/shakacode/react-webpack-rails-tutorial, and tried studying the javascript version of react router and still have no idea on how to tackle it. The react-webpack-rails-tutorial seems really complicated to a unexperienced person. Can I get some insights?


#2

update :
import React from ‘react’;
import {Router, Route, Link, hashHistory} from ‘react-router’

import {HelloWorld} from ‘…/components/HelloWorld’

const Home = () =>

HOI its HOME
;
const About = () =>
HOI its About
;
const Contact = () =>
HOI its Contact
;

export default class Test extends React.Component {

render() {
    return (
        <Router history={ hashHistory }>
            <Route path="/" component={Home}></Route>
            <Route path="/about" component={About}></Route>
            <Route path="/contact" component={Contact}></Route>
            <Route path="/hello" component={HelloWorld}></Route>
        </Router>

    );
}

}

The code above ALMOST works as I imagined. Home, About, and Contact work in localhost:3000/#/home about and contact. But when I go in #/hello, nothing shows up. HelloWorld is from https://github.com/shakacode/react_on_rails.


#3

@dantzchan any solution you got?
ShakaCoder dont seem to help :confused:


#4

@talha @dantzchan This looks like it needs some standard debugging. We’re available to provide individualized help. Please see the ShakaCode coaching plan.


#5

@justin A little help would be appreciated… :slight_smile:


#6

Please get in touch with me directly.


#7

I have similar problem, I want to use react_on_rails in connection with redux and router. If you want we can try to solve it on shakacode slack.