0

I'm working on a coloring demo. I have an SVG file, but I decided to use svgr to convert it to a React component. This will allow me to easily edit its colors and handle onClicks for every individual cell for the user to color in. I want to have all of these components inside a server and send it through express when I fetch for it. However, I'm not sure how to send React code through Express. I looked into server side rendering, but all of the tutorials I have found render to a static index.html. I just simply want to send a component over for me to render. Could someone help me on this? I could elaborate more if needed.

sunny tran
  • 15
  • 5
  • Why do you need to serve it from Experss? Couldn't it be just on browser side? – Maciej Trojniarz Aug 05 '20 at 19:23
  • It's a possibility, but let's say I have a lot of SVGs that I want to render. Client side is fine, but it feels more practical for me to pull things from a server only when I need it. What do you think about this? is there a way? I could keep it on client, but it just doesn't feel right to me. – sunny tran Aug 05 '20 at 19:34

1 Answers1

0

You could try to use some kind of Lazy loading of the JS on frontend side. You can read more on: https://www.newline.co/fullstack-react/articles/Declaratively_loading_JS_libraries/ or React lazy loading - when to use


Maciej Trojniarz
  • 702
  • 4
  • 14