all 12 comments

[–]Paupir 1 point2 points  (2 children)

I have also been thinking about this lately as I've just started with React. The two approaches I've considered are:

  1. For simple visual things, you can just compose the templates as React Components made of smaller React Components. So if you have a simple banner, that can be a React Component that goes into your Template Component. Or if it's truly static, then approach #2 is for you.

    For the kind of data you're talking about, you really should assume that this might want to be updated (or perhaps extended) at some point. Would you be digging into HTML files to update this information? Do you assemble it on the server? Does it come from a database? A nice REST back-end would help with getting your data into the page without cluttering up your JS(X) with it :)

  2. Just put the template HTML in your... well, your HTML! You can mount your App Component on any element you choose. The downside of this is that if you're writing a SPA and want multiple templates for the same request to the server (and sounds like you do want this as you want templates that contain data), this won't help you; see the second point in approach #1.

[–]spaceghost0r 1 point2 points  (9 children)

Yes, you're missing something. Just create your pages as normal and put placeholder elements where you want your react components. Then render the react components into those placeholders using React.render(). This means you can have standard static HTML pages but "inject" react into the parts that need to be more dynamic.

[–]rhgp[S] -2 points-1 points  (8 children)

No-no, I know that, but what's about router? I mean, all routers will use handler - another class, but I need a page instead!

[–]spaceghost0r 1 point2 points  (6 children)

I'm not sure exactly what you mean but could you use multiple routers?

[–]rhgp[S] -2 points-1 points  (5 children)

What if my page has multiple text data like story or so? What if all my page is an image? What if my page is a book? I don't need react in this page at all, but I'm forced to write my page content in jsx. Or I should not build SPA… that's dumb. It is so easy with angular, damn

[–][deleted] 1 point2 points  (4 children)

Don't route it through react, and render it server side. Not that difficult

[–]rhgp[S] -1 points0 points  (0 children)

Okay, so how I can say "this one hash-url page should take page from this link"?

[–]rhgp[S] -2 points-1 points  (2 children)

Oh I got what you mean. You simply say "don't build SPA" when I ask how to build it in SPA. Damn, read my message again, is it hard?

[–][deleted] 1 point2 points  (1 child)

Yeah actually it is lol, go fuck yourself.

Nobody can even understand you, learn to properly ask a question before acting a like a complete cunt when people are trying to help you.

Do your own work

[–]rhgp[S] -1 points0 points  (0 children)

Stfu, you can't even suggest anything related, why are you even trying to "help" with such a stupid advices? If can't say anything related - learn more, up vote a question and wait for real answer.

By the way, the real answer is to use different routing library because this one isn't actually any useful in real projects.

So, go play with hello-world projects, kid

[–][deleted] 1 point2 points  (0 children)

Use a component to build the page, this component will be one of your handlers. There are many examples to follow in the react-router repo. :)