-
Notifications
You must be signed in to change notification settings - Fork 756
Implement server-side rendering #24
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
end | ||
|
||
def render(component, args={}) | ||
# This works because even though renderComponentToString uses a callback API it is really synchronous |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't true anymore, it's sync in master
which will be out in 0.9.
Follow existing pattern of Rails, I think something like And here is a even more fun/crazy idea taking advantage of the existing method react_component(:Foo) # render in client
render react_component(:Foo) # pre-render in server This is tricky. But it is implementable by returning a fake |
OK, I rebased everything on top of master, and force-pushed (not sure if that was a faux pas). I implemented @quark-zju suggestion for |
Yeah, you have to force-push after rebase. |
@JakubMal Yes, the view helper
gets turned into
and then the |
I just want to chime in and say I would love to see this added to react-rails. We're very keen to start using this fork, but obviously sticking to the authoritative source is more supported in the long run. Is there something holding up the Pull Request being merged in that I can help with? |
@JakubMal, what do you think? |
Also, @johnthethird, could you sign the CLA? |
@zpao no problem, CLA has been signed. |
@zpao will let you know here over the weekend |
@robertfall this PR is tied to 1.0.0.pre, and it (1.0.0.pre) needs to be ironed out a bit first. |
So once 1.0.0.pre is finished up there should be no problem merging this in? Unless of course changes in 1.0.0.pre necessitate changes in this PR. Is there anything we can help with for 1.0.0.pre? |
@robertfall I'm testing this PR this weekend, if it's okay it'll be merged right after rebasing. See issues for problems that need to be reviewed before going 1.0.0.rc / 1.0.0 |
@johnthethird could you rebase as soon as you can? I don't want to leave this hanging for too long and I'm pretty sure other PRs will be conflicting. I'll confirm this is good to go sometime today or tomorrow, but in the meantime it would be great if you rebased. |
@JakubMal OK, I rebased, added a commit to change to the sync version of |
@johnthethird I think we'll be able to iron out a couple of issues that I highlighted soon. |
I'm having issues running a pretty simple sample app in production mode, getting this output. Don't know enough to know if I've done something stupid or if this is a real issue, either way thought I'd flag it here in case the README needs tweaking to avoid this. |
@JakubMal I will review your comments and make any appropriate changes. Also, I was able to reproduce @bensmithett issue, so I will take a look at that as well. |
I changed the way the initializer works, which should also fix issue #30 and #31as well. @bensmithett can you give it a try and see if it works for you now? |
@johnthethird yep all good now 👍 |
@johnthethird could you PR |
@johnthethird I just mailed you, why did you close this? |
I force-pushed a new commit for this feature, re-based on the work I teased out to fix #31. It would certainly look cleaner to just open a new PR, but I figured the conversation here was probably worth something. |
|
||
# Watch .jsx files for changes in dev, so we can reload the JS VMs with the new JS code. | ||
initializer "react_rails.add_watchable_files" do |app| | ||
app.config.watchable_files.concat Dir["#{app.root}/app/assets/javascripts/**/*.jsx*"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also watch for files that match: "*.js.jsx.coffee"
This is getting lengthy, just as I didn't want. I think it'll be sensible to just merge as soon as you rebase, and then work iteratively from there. @johnthethird what do you think? |
@JakubMal OK, rebased and ready to merge into master. |
pingping |
Hi! @petehunt This should get merged today 👍 |
Implement server-side rendering
I'll submit unresolved problems from here as new issues to streamline working on this. |
This is so very awesome. Thank you guys for your awesome open source work! Internet high fives! |
😄 🎊 what @keithpitt said, thanks guys! |
<3 been waiting for this one |
very excited about this! |
Add an additional view helper
react_server_component
with the same interface/functionality asreact_component
with the exception that the body of the tag will be filled with a server rendering of the HTML markup. (Im not sure if it should be a different method name or perhaps just an argument toreact_component
? )For thread-safety we use the ConnectionPool class from @mperham to control access to the JS VMs. It is performing well under load in my tests.