Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Can you pass in data from Java to the React app so that it is Server Rendered? #2

Open
protoEvangelion opened this issue Jan 23, 2018 · 2 comments

Comments

@protoEvangelion
Copy link

It's not clear from the code or the demo whether or not it is possible to pass data into the component when the jsx is being transpiled by Java.

I am a frontend guy trying to integrate React into a Java app so I am sorry if my question is not clear!

Great work by the way :)

@fellmann
Copy link
Contributor

Hi, if you want to pass data from Java to the frontend, the jsx is not the right location as it is only compiled once and then cached.
To render data from the user request, just insert some JavaScript into the Thymeleaf template (https://github.com/cronn-de/spring-boot-react/blob/master/src/main/resources/templates/index.html) as described here: http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#script-inlining-javascript-and-dart
Then you can use these injected values to initialize the React state, for example. Does that solve your problem?

@protoEvangelion
Copy link
Author

Hey @fellmann thanks for the quick response!
For SEO purposes I am trying to render JSX on the server at request time.
So my goal is to treat JSX like a templating language.
Do you think that is possible with Java?
Or is that out of reach?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants