-
Notifications
You must be signed in to change notification settings - Fork 755
Add suffix code for context during server rendering #115
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
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Interesting, why is this better than just jamming it into a <script>
window.rubyVar = <%= @some_ruby_var.to_json %>
</script> (My first thought is that this is beyond the scope of react-rails but I could be missing something!) |
If work with Gon, it escapes variables and puts them into script, as you wrote and return only script content for more than one variable, so you can send to context more than one variable, or function and use them later in server rendered component. |
Why would you want to do this instead of passing data in as props? It seems to me that accessing global data is very un-React-y. |
|
I guess I still don't understand why this belongs in the react-rails project. If you need the functionality that Gon provides, why not just use Gon? I don't see why this should be a core component for react-rails when other libraries provide the same functionality in a cleaner way. Alternatively, if you have a single parent component, you could pass the props down from the parent to the children. |
We use Gon, and can't pass any globals when render react component on server, using common functionality. |
I still don't see how this isn't solved by using a parent component and sharing props between children that way. It seems that using a large amount of global data within the React framework would lead to problems down the line, and a small amount could just be passed in via props. Can you provide an example of a case where you would not want React to manage that data? |
Ok, I have some components that using others, and them use global data such as user city, sales cities and some other global vars that cached and send with Gon from different places. And i haven't any global component, that can share props. |
This still sounds like they should be props passed in to each component. I don't understand how adding global variables to each |
I don't add globals to all components, only there they needed, and only during serverside rendering. I think it's not good idea to pass globals as props to component1 or 4, then render them on server |
Maybe someone else wants to speak on this, but I think that passing those Put another way, if is a parent node of , and On Thursday, December 11, 2014, Alexey Zhuravlev [email protected]
|
IMO 👎 for being non-idiomatic React |
Hoping to support more customization of the view helper with #346 ! That way you could distribute a custom helper & renderer in a gem and hook them up with a railtie. |
I hope that new extension point is working for you! |
Allow to send and execute js code during context compiling, before component eval.
This can be usefull, then components are using some variables generated on server, such as generated by Gon https://github.com/gazay/gon