Need some help with my thought clarity on setting up SSR React with Parcel. #9122
Unanswered
abhinav-anshul
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Hi there! Bro u r using the renderToString function from React that is designed to render React components into a string on the server. it expects a valid react element or component as its argument. In your case, is JSX syntax, which needs to be transpiled before it can be used in Node.js. The error you're seeing is because the server-side code does not recognize the JSX syntax. If u want to try a SSR project with parcel and react see this: https://github.com/brillout/parcel-ssr |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hi still need clarification on this |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I am trying to set up a simple Server Side Rendered ReactJS App using react + express + parcel.
This is my
server.js
fileNow the problem is -
It does not read
<App />
component and i believe it wants me to pass vanilla javascript. So when i pass something like this -It runs perfectly and the HTML is being rendered on the screen. Now I would like to know -
renderToString
accepts a react tree as mentioned in the react doc. So why it throws an error when I pass<App />
? If I am simply passing js, then what the use of therenderToString
API?renderToString
using webpack as -Now, why do i need to transpile? Even so how can i achieve this using parcel only? I really do not want to use babel here.
Thanks for reading. If anyone can clear up my thought process on what I'm doing wrong?
Beta Was this translation helpful? Give feedback.
All reactions