I think the Using Blaze with React section should be renamed to Using React Components in Blaze and that we should have a corresponding Using Blaze Templates in React. Or something along those lines.
We’d like to establish the preferred way of doing this, and add it to the guide.
These are the options I’m aware of:
Wrap each template by hand (current recommendation in the guide for accounts-ui)
Thanks, @trusktr. What would you say are the advantages of writing these by hand rather than using a package? It seems like a lot of extra work? Also in terms of everyone needing to solve the same problems?
The only advantage is the satisfaction of having implemented it. But yeah, a package helps people all solve a problem the same with and improve it together. :]
Well, there’s also this feeling of “owning my code” when I write something, as opposed to just using packages for everything, in which case I might not “own my code” and may feel less empowered when it comes to modifying things to be exactly how I want them. Of course, I could also read the code for some package, but sometimes just writing the code leads to a better and more interesting learning experience for me than reading.
Hmm, actually I wonder - would it be better to just list the code in the guide than recommend a specific package? What are the tradeoffs?
Anyway, of the options provided, looks like thereactivestack has the most popular one (maybe because it’s in their boilerplate app?), but the gwendall and gadicc ones have a similar design.
OTOH, it’s less that 50 lines of code in every one of the packages. So it seems a bit like bikeshedding to pick which one is the best since they probably do the same thing.
It seems like @gadicc yours is actually the best, because you handle the props and variable setting in the clearest way. Let’s leave this thread open for another day or so, and then recommend your package if nothing dramatic comes up.
Thanks. I felt like a slightly higher standard was needed in case it does go in the guide so I added some tests, CI and some initial code towards SSR. The latter is something useful that could come in via an update vs static code. I’m still interested to hear other opinions though.
Hey, this isn’t true. gadicc:blaze-react-component is still actively maintained. The issue in question (which was answered in 3 hours, I might add) was a result of using static-html instead of the templating package. In the newly released version, we clarify this use case both in the README and with a more helpful error message if the template is not found:
No Template["test1"] exists. If this template originates in your app,
make sure you have the `templating` package installed (and not, for
e.g. `static-html`).
I still think it’s better to have a centrally maintained package, that addresses unanticipated edge cases and adds new features (e.g. SSR following progress on community Blaze work). As with all my projects, PRs are always welcome and I’d love for the package to be community maintained too.
The advantage to hand-rolling it in, is that you can begin/continue the process of re-engineering your other code style into the new code style. Eventually you could then in a future version disable the older compatibility layer.