News for hackers. Stuff that matters.
Re:React Router v4 FAQ by zachrose on Friday September 16, 2016 @01:11AM (#12511979)
Disclaimer: I am a former Backbone-using developer who hasn't done much front-end work since React became so dominant. I just don't understand this project. I'm commenting to explain my confusion in the hopes that somebody else's perspective can help me see why React Router is helpful.

When React came out it was billed as just the "V" in client-side MVC. While just about everybody has their own understanding of MVC, my interpretation of the "V" was that it was about things you can see. So React was going to take my data and maintain a UI based on that data without thrashing on the DOM. Cool!

But nobody seemed to do that at first. They put HTTP requests all sorts of stuff inside the React component, and then handled the requesting, processing, and rendering as internal details to the component.

Then the Flux idea came around, which was (I think) to brand one-directional events as "actions" and then smartly cache/reduce an ongoing stream of actions into a single data structure that represents lots of potentially disparate parts of your application. This also made some amount of sense to me.

Surely there would be lots of things that could create actions: incoming DOM events representing a user's intentions, ajax responses that have potentially new facts about the world, websocket events, signals from the camera and microphone, and anything else that might cause a change in the overall state of the page. With the possible exception of DOM events, which the view should quickly translate into meaningful actions anyways, these actions are really not related to the "V" at all.

So what benefit would I get from authoring the logic of URL-change handlers in JSX? Wouldn't it be nicer to write some JavaScript that handles those events and transforms them into actions?

Re:React Router v4 FAQ by sotojuan on Friday September 16, 2016 @12:24PM (#12515110)
The V in MVC was a mistake IMO and it was eventually removed from their site.
Re:React Router v4 FAQ by zachrose on Friday September 16, 2016 @12:47PM (#12515305)
Why do you think it was a mistake?
Re:React Router v4 FAQ by sotojuan on Friday September 16, 2016 @12:49PM (#12515323)
It's not how most people end up using React and it just causes confusion.
Re:React Router v4 FAQ by morenoh149 on Friday September 16, 2016 @03:59PM (#12516880)
Flux (the data management architecture for react apps) eschews MVC altogether. Maybe that's related.
Re:React Router v4 FAQ by wesleytodd on Friday September 16, 2016 @09:06AM (#12513683)
> So what benefit would I get from authoring the logic of URL-change handlers in JSX?

I don't get it either. I thought we were over describing program behavior in XML?

Re:React Router v4 FAQ by jmakeig on Friday September 16, 2016 @01:24PM (#12515640)
I'd love some backstory on this too. I (kind of) understand JSX for HTML, but declaring routing rules seems very far from that.
Re:React Router v4 FAQ by wesleytodd on Friday September 16, 2016 @05:03PM (#12517333)
If you have a hammer everything looks like a nail?
Re:React Router v4 FAQ by barryhoodlum on Friday September 16, 2016 @06:23PM (#12517813)
Yeah, this is exactly my first impression (I've never really looked into any past version of React Router either).

Why is routing being declared in components in the first place? It seems counterintuitive. There are obvious downsides - so what are the upsides? The README gives no clues.