Isomorphic JavaScript with React and Node
reactjsnews.com
reactjsnews.com
I can't decide whether I love or hate React w/ Flux, but the one thing I'm sure of is that the documentation was written by someone who had pain in some framework I haven't had experience with. I've used Knockout extensively in a medium sized web application and reasoning about the source of data updates and dependency invalidation hasn't really been a problem at all. And that's the perfect example of the data-binding and dependency modeling which seems to be what React is eschewing. shrug Either way I'm still intrigued and will give it another go when I have more free time.
In other words there is no one size fit all solution, but I think we all know that already.
The biggest problem is that renderToString follows a different component life-cycle path. In particular, componentDidMount isn't called. Although this makes sense (there is no actual DOM to mount, just the virtual DOM), this is typically where server-side interaction is handled. Without this life-cycle hook, it's more difficult to build components that behave similarly on the client and the server.
In addition, one must set up abstractions around things like API request transports (e.g., jQuery on the client and request on the server) that have different environmental requirements. This part is more manageable.
There is an intrinsic connection between state and external environment that must be grasped before you can start building isomorphic modules.
I'm not sure why jQuery and React would ever be used in the same project. If you want an isomorphic solution to retrieving data check out https://www.npmjs.com/package/browser-request and enable and convince 3rd parties to enable CORS on HTTP endpoints.
Thanks for the recommendation. The only reason for jQuery is the occasional external dependency and the XHR wrapper.
I've been playing [1] with isomorphic forms using react-router - it uses a static willTransitionTo() hook on the constructor of components which do route handling for the equivalent of request handling, which seems to work well in the limited cases I've tried so far.
For API requests, you can use a request library which has the same API on client and server - superagent and axios seem to work well.
In the end, you are only going to be able to go so far on the server before you have to wait for the client side mounting event. You can render a complete page, with forms and the rest, but it won't be interactive until the mount anyway.
>Several terms used in category theory, including the term "morphism", differ from their uses within mathematics itself
There may be other aspects of the appropriation of sexy math terms which you find problematic, but the mere act of borrowing established terms doesn't seem problematic in its own right.
fwiw, I don't like JavaScript and I am interested in and partial to mathematically and logically grounded languages. otoh, I don't care what names JS developers give to their constructs either.
I don't see anyone complaining about the use of the word "function" instead of "subroutine".
You can do all the reverse etymology you want, but in the end, we all know this is just a word that JavaScript kids are using because it makes them feel cool.
This sort of reminds me of when that weird kid nobody likes tries on a new nickname (like "The Chief" or "Serpent" or "T") and I have to kindly say, “Hey bingo/bud, I'm really sorry, that nickname is just not happening".
To your other point, I'm not against reappropriating words in different contexts to describe ideas metaphorically. In this particular case, isomorphic is already defined in a programming/math context. You're not so much reappropriating a definition to a new contract as you're making an existing word sound more ambiguous in the same context by diluting it. I think the reason people are so passionate about not diluting this term is because they want people to understand and really appreciate the value of isomorphisms. They're not being bullies to make themselves feel superior, they're trying to protect an idea from being misrepresented.
We already have words that mean exactly what is trying to convey. Taking a word that doesn't and adding it to that pool (especially when isomorphic has a meaning in mathematics and computer science already - e.g. two functions are isomorphic if for all inputs they produce the same output, even if their implementation differs) is a bad idea.
Edit: And we who argue that isomorphic is not the right word for this concept already know what the word means. We also know what the words in the definition mean, and also its usage, which is as a relation between two elements in the same set. Saying something is isomorphic on its own is against the definition.
Other examples: ajax, lamp, nosql, soa ... they may be buzzwords, but they are helpful. I don't see the problem here.
Nevermind that this concept is not even worth a name.
Anyway, I find the term useful.
When is "sometimes"? Who knows. Seems like a bad idea to rely on this.
https://github.com/chadpaulson/react-isomorphic-video-game-s...
That said, I am currently working on a more refined approach to isomorphic flux and async in a new project that I hope to open source later.
What do you use https://github.com/andreypopp/react-async for?
I was trying to wrap my head around that the read the warning:
"WARNING: Keeping data in React component's state is a bad idea. React component's state is for purely UI state, like "if this dropdown openned or closed?". In light of that, React Async is an anti-pattern so you shouldn't use it unless you are 100% sure you need it"
I am currently working on a new project utilizing different modules (alt instead of reflux and react-router instead of react-router-component) which does not utilize react-async.