-
Notifications
You must be signed in to change notification settings - Fork 759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attempting to use React-Router #472
Comments
having trouble rendering the routers from rails as well. how were you able to render via render_component? |
Do you have in your App component ? I do believe that's where the components of the route are generated |
Sadly since this is inside rails, there's no App component. I have specific features that have the mother "system" component, but no App component that encompasses everything if that's what you mean? |
I'm a complete newbie in this as well, but if you can humor me with this attempt. Try setting the root path as DefaultRoute, then create an App component that returns only |
I've made React-router work with this gem. Here is my solution:
Good luck. The only problem I got is when the page renders a React component, react-rails-hot-loader doesn't work within that component, it works with child components |
Thanks for sharing your solution! I hope it works for others, too! |
Hi, Thanks for sharing the solution, I got this working on my existing rails app. I cant seem to get it to work on pre-rendering though, it keeps giving me the error: Google shows this to be that it cant find the history for the Router, which are defined in the js assets: I tried putting these in the server_rendering.js along with react router include, but it still throws the same error. I attempted to put the components after the declaration of the vars, but then the server renderer couldnt find my components... I cant seem to figure out how to debug ExecJS, but it seems to me there is some kind of error with the definitions causing the whole process to fail... Has anyone gotten router to work on pre-render? |
Thanks @origamih. Latest version of react-router on unpkg has a new url format: https://unpkg.com/react-router@4.1.1/umd/react-router.js |
For react-router-dom 4.x
(I'm guesing this is not the complete list, but you get the idea) |
how to ssr? |
I know this is old issue, but i am trying to wrap my head around similar issue, I am struggling to connect wires in rails router to forward requests to frontend router, and to make it not look like whole page is loading. |
So I'm trying to use React-Router in my rails project with React-Rails and it seems to not want to correctly display the component I want when I'm on a specific route.
Inside
app/assets/javascripts/components/routes.jsx
:In the above, I'm only using the setTimeout because it seems to not be able to find anything on page load and says that there is no id main inside the document. setTimeout fixes this.
The App component is just an empty component because I really do not care about it one bit. I'm only rendering a react component when I'm on the /messages route (which on my index.html.haml I am doing the
= react_component 'MessageSystem
in the corresponding rails view.I really only want the /messages to display the MessageSystem. That means when I'm on
localhost:3000/messages
it adds the history hash after the/messages
so now it looks likelocalhost:3000/messages#/?_k=vaeumq
.When I use the React Dev Tools, I see my MessageSystem component when on the page, and then under it I see the
Router
and the path seems to be just "/". What I think it should be ispath="/messages"
.Was wondering if anyone else has had any issues using React-Router with react-rails? Thanks
The text was updated successfully, but these errors were encountered: