News for hackers. Stuff that matters.
Re:Vue.js: the good, the meh, and the ugly by stupidcar on Thursday July 05, 2018 @05:05PM (#17466848)
If plain, idiomatic React so great, why does every semi-complex React app end up bringing in a separate state management framework like Redux or MobX?

The reason is that while you may be able to break up your HTML into a composable hierarchy of purely-functional components, the actual data and state you need to distribute to them has a structure that is completely unrelated to how its laid out in the DOM. In a complex web app, a component nested twenty levels deep may need to display pieces of information, like the user's date of birth and the current temperature on Mars, that none of its parent controls cares about.

At that point, you can either bite the bullet and pass state through layer upon layer of props, completely eliminating any semblance of separation of concerns in your component layering, or inject state into your components via some other mechanism, like Redux/MobX/Context. At which point, JSX is basically just another fancy HTML templating library.

"Idiomatic" React is a fun game to play when doing basic examples, using something like a todo manager, but as soon as you're in the real world, you hit its limitations very quickly.

Re:Vue.js: the good, the meh, and the ugly by allover on Thursday July 05, 2018 @05:29PM (#17466997)
> If plain, idiomatic React so great, why does every semi-complex React app end up bringing in a separate state management framework like Redux or MobX?

Sadly it seems that's mainly been cargo-culted. It's not the case that React+Redux is the equivalent to say Angular, but by some unfortunate accident due to Facebook's announcement of Flux, and then the hype around Redux as a 'better Flux', people started assuming React+Redux is what is needed to build a React app.

Meanwhile Dan Abramov, Redux creator says [1]:

> Flux/Redux is meant for big apps with complex nested UIs that have many independent parts but share common caches of data.

That's not "every semi-complex React app". In most "semi-complex React apps", most state can be derived from the route (e.g. react-router) or is relatively local. Redux is not required.

[1] https://twitter.com/dan_abramov/status/732719257579065345

Re:Vue.js: the good, the meh, and the ugly by atombender on Thursday July 05, 2018 @06:43PM (#17467490)
There's unfortunately a thin line between cargo-culting and attempting to follow the mainstream.

As developers we can't all be building tools. We choose tools that others build for us, so that we can get our job done. Soemtimes I'm interested in going "one layer down" and build tools, but it's almost always a distraction; we want off-the-shelf products like React and Redux. We need to pick stable tools that promise some sort of longevity. We also need to pick tools where best practices and idioms have been established.

To do this we have to trust someone else's opinion and try to gauge which solutions have the best prospects. This means not just evaluating software based on its own technological merits, but also listening to what "the community"/"the industry" seems to be rallying around; you don't want to be stuck using a library that nobody is maintaining, just as you don't want to be stuck using something that's just badly designed.

When we started using React, there was no state management framework available, and everything was handled somewhat ad-hoc. Then Facebook described Flux, and we realized they were onto something, so we started using their patterns, with some simplifications where theirs seemed overly complicated. Then Redux came along and seemed like a better way to do things.

At each point there was uncertainty about what best practices and "idiomatic" solutions would turn out to be, because the technology was immature. I don't think anyone was cargo-culting. It was just that a lot of people were busy trying to create things, and when there isn't clear guidance, and the alternative is going back to Backbone or jQuery or something, then you just forge ahead, trying to do fit the pieces together.

Re:Vue.js: the good, the meh, and the ugly by allover on Thursday July 05, 2018 @07:02PM (#17467610)
But if you looked at the official React docs the answer was always 'setState' and embracing components, that was the whole promise of React to begin with. Not once did the React team/docs ever say you needed Flux to build a React app. All of those answers you got were cargo-culted from the community.

Can you really look at where the community is, the perception that still exists that React+Redux is necessary, projects like redux-form (that now admit Redux was a poor fit for forms) and honestly say no cargo-culting happened?

Sympathy for 'attempting to follow the mainstream' though, I understand that. Personally I stuck with Backbone for years longer than most, avoiding the Angular/Ember wars, and the early days of React+Flux til the React ecosystem had matured a little, before jumping over to React at which point it was clearer that Flux/Redux were being misused.

Re:Vue.js: the good, the meh, and the ugly by jakelazaroff on Thursday July 05, 2018 @11:37PM (#17468669)
The official docs originally described React as "the V in MVC" [1], so the assumption about needing another layer to handle state and business logic didn't come from nowhere.

The claim isn't that there's no cargo cult around the React ecosystem — but not everyone writing React code is approaching it with experience, which means they try to pick up best practices from other people. That's not "cargo culting"; it's a reasonable thing to do when you have to solve a problem you don't know how to solve!

Ultimately, people aren't being "tricked" into using these tools. They proliferate because they solve real problems people have, and a lot of people would rather work with a popular and well-documented solution (with known advantages and drawbacks) than trying to forge their own path and seeing how it goes.

[1] https://github.com/facebook/react/pull/7012

Re:Vue.js: the good, the meh, and the ugly by atombender on Thursday July 05, 2018 @07:16PM (#17467686)
Can we blame all the bloggers who take upon themselves to explain what the best practices is? Absolutely. There are also projects (like React Forms and React Router) that clearly led down a path of confusion. But it's hard to blame the developers who read those blogs and try to figure out what they should be doing.

I never got the impression, even from the start, that setState() was a good solution, by the way. But it's not like the React authors were completely sure of where the right design was, either. Flux, for example, as it was originally described, appears completely overdesigned at this point. The good design is to be found in Relay and GraphQL.

Re:Vue.js: the good, the meh, and the ugly by allover on Thursday July 05, 2018 @07:41PM (#17467819)
> Can we blame all the bloggers who take upon themselves to explain what the best practices is?

It's not really about blaming bloggers.

It's really on software team leads and senior engineers to not just follow blog posts blindly. They should be pushing back on bad advice like redux-all-the-things, because to a senior software engineer the tradeoffs of something like Redux should be fairly obvious.

> The good design is to be found in Relay and GraphQL.

Nah again, good example to question what you read/hear.

GraphQL is great from a front-end point of view but complex to implement in the backend, so it really depends on your use-case whether that backend complexity is worthwhile.

Re:Vue.js: the good, the meh, and the ugly by _hardwaregeek on Friday July 06, 2018 @01:14AM (#17469040)
Could you provide a source for the maintainers of redux-form admitting that Redux was a poor fit for forms? I'm inclined to agree and am kind of interested to see their reasons.
Re:Vue.js: the good, the meh, and the ugly by allover on Friday July 06, 2018 @05:24AM (#17470038)
Yep, sorry I should have included the reference. This post is by the redux-form creator, in which he states why it was a bad idea, and announces its 'spiritual successor': https://codeburst.io/final-form-the-road-to-the-checkered-fl...

> Also, everyone high up in the React community, including both inventors of Redux [1], say that Redux is not the best place to keep form data. Oops.

[1] https://github.com/reactjs/redux/issues/1287#issuecomment-17...

Re:Vue.js: the good, the meh, and the ugly by acemarke on Friday July 06, 2018 @11:07AM (#17472001)
Now, it _does_ depend on your use case.

An isolated login form? Yeah, no point keeping that in Redux - it's not being shared, it's not being persisted, there's no real need to track the history of changes. But, there are certainly situations where you might want to keep some form data in Redux.

As a specific example from my own app: we show some polylines on a 3D globe, and allow the user to edit them. We need to be able to live-update the point locations and labels on the globe as the user edits them, allow resetting edits, and still be able to show the original values elsewhere in the UI. Keeping all that data in Redux makes it easy to do so.

The Redux FAQ has a list of suggested rules of thumb for deciding what state should go in Redux: https://redux.js.org/faq/organizing-state#do-i-have-to-put-a... .

Re:Vue.js: the good, the meh, and the ugly by mosdl on Friday July 06, 2018 @04:27PM (#17474847)
You can achieve all of that with a singleton that is shared and some events (and do some of your own batching). No need for another dependency and you save bloat size.
Re:Vue.js: the good, the meh, and the ugly by acemarke on Friday July 06, 2018 @06:58PM (#17475753)
Well, the whole app is built around Redux in the first place :)
Re:Vue.js: the good, the meh, and the ugly by drunknhik on Sunday July 08, 2018 @07:19AM (#17483226)
To me this underscores the most unspoken point. Redux is meant for when you specifically want to build your app around redux. It's not meant to tack on some global store to an existing UI. It is UI agnostic way of separating your business logic and side effects from the UI iself (which could be react, vue, angular, whatever)
Re:Vue.js: the good, the meh, and the ugly by acemarke on Sunday July 08, 2018 @09:03AM (#17483573)
For the most part, yeah.

Now, the other app my team works on is built with Backbone/Marionette. We've introduced React and Redux to it, and are progressively refactoring over time. It works, although we've got some rather ugly code in several places (some data is in Backbone collections, other data is in Redux, and occasionally some bits of data are mirrored in both places).

I wrote about some of the techniques we're using to integrate them here: https://blog.isquaredsoftware.com/2017/07/react-redux-backbo...

Re:Vue.js: the good, the meh, and the ugly by bananadonkey on Thursday July 05, 2018 @07:50PM (#17467859)
As one of a small group of maintainers of the build tools of our most complex app, I can concur with this. Yesterday I spent 4 hours fixing a single build/parse issue between dev and prod.

I also spent just 1 hour completing multiple RFCs in another app built with create-react-app using redux/connect as a purely syntactic-sugar state propagation layer.

I love the complexity and feeling of fulfillment for triumphing in the former scenario, but it is definitely much more of a distraction than anything else.

Re:Vue.js: the good, the meh, and the ugly by ppseafield on Thursday July 05, 2018 @09:54PM (#17468356)
I remember when I first started to try and learn React there was only a handful of words and a vague diagram from Facebook about its Flux architecture. And after that there were many, many similar state management libraries. That some in the community picked a smaller one that had in-depth documentation and emphasized stateless / functional style programming is not terribly surprising.

IIRC there were a lot of comments about having to pass props to children constantly (without using a state management library). Seems like it's a lot easier to not use a state management library now that an official, non-experimental Context API exists. But remember, this was only added a few years later.

Re:Vue.js: the good, the meh, and the ugly by ilovecaching on Thursday July 05, 2018 @05:43PM (#17467104)
Agreed. Cargo culting is the main issue. The solution is to try and remain unbiased, and not look for direct synonyms between two very distinct approaches to managing user interfaces.
Re:Vue.js: the good, the meh, and the ugly by olfactory on Thursday July 05, 2018 @10:34PM (#17468457)
Well, FWIW js is not the most friendly language for functional programming. I'd argue that the trend toward immutable.js and redux occurred partly because rest/spread syntax was/is relatively confusing, and so immutable patterns without a library feel less elegant until one really groks the somewhat visually opaque semantics of the rest/spread syntax.

Redux also offered a simple approach to the "action bus" idea from Flux, but omitted first class async support, etc. React itself also somewhat overlooked async patterns, which created the idea that their absence was by design and so an additional (opinionated) library was appropriate.

In sum I'd argue that React actually fights against js quite a bit and that it will truly come into its own once reason gets more mindshare.

For those of us who invested heavily in react as all this was becoming clear (and being ironed out) I hope we learned enough to allow better decision making in the future.

Also, React has a few "on by default" performance enhancements that are a bit conceptually confusing and create something of a mismatch with the functional approach.

But still it's difficult (and unpleasant) to imagine the world without React.

Re:Vue.js: the good, the meh, and the ugly by jbergens on Friday July 06, 2018 @07:42AM (#17470591)
Also, MobX is for most devs easier to understand and use than Redux and more similar to Vue and Angular. I think most small react projects should start with no external state management or mobx and only switch if they need it. Unless they already know redux very well and think it suits their project.
Re:Vue.js: the good, the meh, and the ugly by Globz on Friday July 06, 2018 @11:18PM (#17476774)
Just to add some weight to your opinion about Redux being cargo-culted take a look at this video

https://youtu.be/S6lwJ6Rixnc?t=6m

Re:Vue.js: the good, the meh, and the ugly by erikpukinskis on Friday July 06, 2018 @02:22AM (#17469358)
> the actual data and state you need to distribute to them has a structure that is completely unrelated to how its laid out in the DOM.

It took me many years to realize this. I think very few front end developers understand this. And more problematically: very few framework devs seem to understand it.

Stated another way....

Your tree of UI widgets, and

Your tree of data which feeds those widgets

... are two orthogonal trees.

If you are a front end dev and you haven’t spend time wrestling with that, I strongly recommend it. It’s extremely likely your front end architecture is suffering because of it.

React take the strongest stance on this matter, by making the interface to every widget be one giant shared global. But globals are bad, so while it’s good they acknowledge the situation, they mostly punt on the question of how to deal with it.

Re:Vue.js: the good, the meh, and the ugly by bryanrasmussen on Friday July 06, 2018 @03:14AM (#17469569)
>Your tree of UI widgets, and

>Your tree of data which feeds those widgets

Not with a well-designed XML format and XSL-T! But hmm, nobody seems to use that anymore either.

Re:Vue.js: the good, the meh, and the ugly by mattmanser on Friday July 06, 2018 @04:16AM (#17469795)
Having done this in the wild a while ago, it seemed to be hard for most of the other developers to do anything complex with it.

You either really got it and then could do wonderful things, or you sorta muddled along with it and it was ok but it was like they were wearing a straitjacket.

I made a pivot table control out of it, with almost all the logic inside the XLST, it was amazingly fast compared to IE6's javascript at the time. I remember that Blizzard used it for the WoW online character viewer which was streets ahead of what anyone else was doing.

Also there's a DailyWTF about someone doing this on a large app, which brought the developer out of the woodwork to defend it who said in fact it wasn't a WTF, it was deliberate, it worked, loads of people loved it. Which prompted a huge debate about how it was actually kinda good, but just too high a learning curve (which is the death knell of many a tech).

Personally I don't miss it. The best way I can sum up XML/XLST up is that it made me feel clever, and now I know that when I start feeling clever about my code that's a sure sign I'm making something that's going to be a nightmare to maintain.

Re:Vue.js: the good, the meh, and the ugly by pjmlp on Friday July 06, 2018 @05:16AM (#17470017)
Once upon a time my web site was doing all the rendering via XML/XLST, and I looked forward to what might have been Web Components via the XML Components standards.

Oh well, at least Web Components seem to finally be around the corner, a decade later.

Re:Vue.js: the good, the meh, and the ugly by mattmanser on Saturday July 07, 2018 @05:00AM (#17477740)
Yes, the lack of reusable controls in hrml is utterly crazy!
Re:Vue.js: the good, the meh, and the ugly by matwood on Friday July 06, 2018 @07:46AM (#17470602)
> Having done this in the wild a while ago, it seemed to be hard for most of the other developers to do anything complex with it.

Same. Long ago I replaced an expensive Crystal Report solution with reports delivered as XML/XSLTs that used IE's feature at the time of applying the XSLT at the browser. It worked very well and provided nice interactive reports. I also wrote a bunch of cookbooks (for lack of a better term) that allowed the business analysts to create additional reports.

Re:Vue.js: the good, the meh, and the ugly by Falling3 on Friday July 06, 2018 @12:36PM (#17472800)
> streets ahead

Pierce? Is that you?

Re:Vue.js: the good, the meh, and the ugly by mattmanser on Friday July 06, 2018 @01:41PM (#17473465)
No, I'm from the UK, it's a common idiom over here.
Re:Vue.js: the good, the meh, and the ugly by avinium on Friday July 06, 2018 @05:54AM (#17470160)
Wouldn’t happen to have a link to that DailyWTF would you? Would love to read the discussion.
Re:Vue.js: the good, the meh, and the ugly by mattmanser on Friday July 06, 2018 @06:44AM (#17470337)
I was having trouble earlier, but have tracked it down:

https://thedailywtf.com/articles/Sketchy-Skecherscom

The featured comment at the bottom is from the original devs.

One of the early comments is that it only worked properly on Firefox, which is wrong. IE6+ had excellent, extremely fast XSLT support.

The company I worked for at the time actually had an enterprise app that didn't work properly on FF as it relied on some IE only functionality, some sort of VBScript controls you could embed in IE that I forget the name. They dropped support for them in IE8 or 9. The app was otherwise excellent, basically a sort of dropbox + basecamp for the construction industry before dropbox + basecamp were even made, users loved it. The founding developer was the best developer I have ever known (his quirk was that he'd often forget to rename his functions after prototyping something so a lot of his methods were called Something or Thing or Something2 and we'd have to rename them later to make it clear what they did).

We had a SQL helper that would allow you to write XPath in the SELECT names something like this (I have totally forgotten xpath by now, but hopefully you get the jist):

    SELECT c.CompanyId [@companyId], c.Name [@companyName], 
      o.OrderId [/orders/order/@orderId], o.Name [/orders/order/@name], o.Quantity [/orders/order/quantity]
    FROM Orders o
    JOIN Company c ON o.CompanyId = c.CompanyId
    ORDER BY c.CompanyId
And it would spit out appropriately nested and structured XML like:

    <companies>
      <company companyId="1" name="thing">
        <orders>
          <order orderId="142" orderName="Sally's Order">
            <quantity>1</quantity>
          </order>
          <order orderId="156" orderName="Sally's Other Order">
            <quantity>1</quantity>
          </order>
        </orders>
      </company>
      <company companyId="2" name="different company">
        ..etc
       </company>
    </companies>
     
It was actually pretty nifty, you only got exactly the data you needed for the page, but meant often our business logic was in SQL statements. It did make me realise how infrequently you actually re-use specific data queries and a lot of people over-egg how much data re-use there is or logic sharing that is actually required in a real-world app.

Because you had the XSLT on the page, you could make it dynamic, just post back for the new XML on a drop-down change, button-click, etc.

Another story from there is that they made their own version of jquery just before jquery rose to prominence. It was a nightmare to debug, that fully got me onboard the jquery train.

Re:Vue.js: the good, the meh, and the ugly by ethbro on Saturday July 07, 2018 @10:24AM (#17478584)
> It did make me realise how infrequently you actually re-use specific data queries and a lot of people over-egg how much data re-use there is or logic sharing that is actually required in a real-world app.

Agreed. Possibly a microsymptom of the "business only does boring things, developers do interesting things" mindset.

In my experience, one needs to constantly guard against thinking anyone else is mindlessly turning a crank. In fact, they're likely doing just as complex and interesting stuff as you, only with different tools.

Re:Vue.js: the good, the meh, and the ugly by bryanrasmussen on Friday July 06, 2018 @07:04AM (#17470435)
Looking at it, xsl:for-each inside of xsl:for-each should be xsl:template with it's own mode.

however it's also really too trivial and really straightforward and boring as a piece of code to be mentioned as a WTF, having difficulty understanding that code would just be a case of not understanding the language, which is also a thing that happens.

Re:Vue.js: the good, the meh, and the ugly by mattmanser on Friday July 06, 2018 @07:22AM (#17470516)
I seem to remember that was just a practical thing, sometimes you couldn't be bothered to split it into two.

The context of that article was more that doing XML/XSLT at all was a WTF.

Re:Vue.js: the good, the meh, and the ugly by pyre on Friday July 06, 2018 @08:05AM (#17470705)
IIRC, Colloquy (a macOS IRC client) used to do this. Each IRC channel was basically an XML feed, and the theming was just XSLT applied to the XML feed and the output displayed in a WebView widget.
Re:Vue.js: the good, the meh, and the ugly by jrs95 on Friday July 06, 2018 @06:43AM (#17470336)
I think this is the issue Relay tries to solve. It basically just allows components to declare which part of the data tree they are concerned about without having to have knowledge about the data that other components need.
Re:Vue.js: the good, the meh, and the ugly by boubiyeah on Friday July 06, 2018 @11:18AM (#17472115)
You wrote "React take the strongest stance" but you meant redux right?
Re:Vue.js: the good, the meh, and the ugly by erikpukinskis on Monday July 09, 2018 @05:21AM (#17488955)
No, React has a notion of a single giant state object, right?
Re:Vue.js: the good, the meh, and the ugly by boubiyeah on Wednesday July 11, 2018 @05:24PM (#17510405)
No. Vanilla React just give you the option to store state of any size in any component.
Re:Vue.js: the good, the meh, and the ugly by ilovecaching on Thursday July 05, 2018 @05:39PM (#17467070)
So I see where you're coming from. To first address Redux, etc, React has no opinion on state storage, it's a feature not a bug. Obviously you need to store state somewhere, and Redux, Relay, etc are just tools to address that concern. But that's really unrelated to what you're trying to address, which is coupling between leaves that have shallow common ancestors, but are themselves quite deep. Although in my experience a good website does group related pieces of information, and so well organized state often maps easily to a well organized UI, functional programming gives us the tools to avoid deeply nested expressions regardless of your application (or even your framework).

One thing to realize is that you always get to decide on the granularity of your compositions. It is not necessary to build a deep hierarchy if you design the granularity of your interfaces correctly. Another great tool is higher order functional programming, such as passing components to components (via children). In this way, it is easy to describe generic interfaces and supply specific pieces of data without having the intermediary interfaces know or care about that data. Another approach, akin to using something like the state monad, is to use Reacts context feature, but this is rarely needed, in my experience.

Personally I make heavy use of higher order components, and I find I rarely exceed a component tree height of three.

Re:Vue.js: the good, the meh, and the ugly by kalkut on Friday July 06, 2018 @04:19AM (#17469806)
As someone one who rewrote a React/Redux project with bare React : Everything in your post is true, I made the same observations and I reached the same conclusions.

Right now with a few devs it is going very well but I do worry about on-boarding people who are not proficient in functional programming.

React code without a global state management library is very pleasant and easy to read/understand for many, but for some it is not always obvious to write. You may have to spend more time code reviewing and training newcomers who will sometimes feel like their task is impossible without Redux. I have yet to see if those requirements can still hold for a big team but I think it is possible.

My current opinion on Redux is that it is best suited for existing project migrating to React because you may inherit very odd relationships between the view and the data and Redux will avoid you a lot of pain on this regard. A new project should avoid Redux & co as long as it can.

Re:Vue.js: the good, the meh, and the ugly by ipntu on Friday July 06, 2018 @04:32AM (#17469863)
> Personally I make heavy use of higher order components, and I find I rarely exceed a component tree height of three.

That's my experience as well. If you use a deep component hierarchy you have bigger problems than those solved by Redux, VueX or the Context API.

Higher order components or even simple functional components are really underrated when it comes to making your application simpler to reason about and to maintain.

Re:Vue.js: the good, the meh, and the ugly by porker on Friday July 06, 2018 @03:05AM (#17469535)
Is there a blog post explaining higher order components in more detail, preferably with examples?
Re:Vue.js: the good, the meh, and the ugly by akie on Friday July 06, 2018 @04:30AM (#17469854)
Higher Order Components are like Aspect Oriented Programming - it takes a component and adds some stuff to it. It can add that stuff to any kind of component. That's all you really need to know.

Examples of HOC are the connect() call from Redux, or the withNavigation() from React Navigation, or injectIntl() from React-Intl. These respectively add Redux functionality, navigation functionality, and internationalization functionality to your component.

I think the name "Higher Order Component", like many things in the React world, is poorly chosen and actually obscures what it is, how it works, and makes it look more intimidating than it really is. It's technically correct (like 'reducer' is), but communicates nothing.

Re:Vue.js: the good, the meh, and the ugly by davedx on Friday July 06, 2018 @05:11AM (#17469996)
I agree.

It's effectively a replacement for the old React mixin system.

It happens to use functional programming methods, but that's an implementation detail.

Re:Vue.js: the good, the meh, and the ugly by acemarke on Friday July 06, 2018 @11:08AM (#17472013)
Yep, lots! See the "React Component Composition" section of my React/Redux links list: https://github.com/markerikson/react-redux-links/blob/master...
Re:Vue.js: the good, the meh, and the ugly by kalkut on Friday July 06, 2018 @04:21AM (#17469818)
The doc is very detailed with good examples : https://reactjs.org/docs/higher-order-components.html
Re:Vue.js: the good, the meh, and the ugly by DougBTX on Thursday July 05, 2018 @05:31PM (#17467008)
React was advertised from the start as the V in MV-whatever, so that seems like an overly restrictive definition of "idiomatic".

> At which point, JSX is basically just another fancy HTML templating library.

JSX is optional syntax sugar; my team uses React and Redux heavily, but we've opted not to use it.

HTML templating is great actually, all the rendering is data -> UI.

If you go back to the early Rethinking Best Practices presentation[0], it boils down to asking why client side development isn't like like HTML templating. The answer is that updating the entire page DOM on every change is unworkable, there needs to be support for partial updates. That's what React offers, a return to the data -> UI paradigm, without having to write a secondary code path for partial updates.

[0] https://www.youtube.com/watch?v=x7cQ3mrcKaY

Re:Vue.js: the good, the meh, and the ugly by acemarke on Thursday July 05, 2018 @06:16PM (#17467327)
Out of curiosity, what are you using instead of JSX? Plain `React.createElement()` calls, `createElement` aliased to a shorter variable like `e`, or something like the `react-hyperscript-helpers` library?
Re:Vue.js: the good, the meh, and the ugly by DougBTX on Thursday July 05, 2018 @07:37PM (#17467801)
We’re still using https://www.npmjs.com/package/react-dom-factories for plain DOM elements, so code looks like

    dom.div({ props }, ...)
For our own components, we export the output of React.createFactory https://reactjs.org/docs/react-api.html#createfactory rather that the component itself, so rendering code looks like:

    MyComponent({ props }, ...)
I realise that both of those are marked legacy, with a nudge towards using JSX instead, but they are pretty thin wrappers around createElement so it seems like a small dependency.
Re:Vue.js: the good, the meh, and the ugly by spiritcat on Thursday July 05, 2018 @06:52PM (#17467543)
it's funny how originally jsx is what kept me away from react, and now it's what keeps me from leaving.
Re:Vue.js: the good, the meh, and the ugly by kibibu on Friday July 06, 2018 @02:12AM (#17469320)
It's funny how everybody hated E4X when Adobe and Mozilla were doing it, and love JSX now.
Re:Vue.js: the good, the meh, and the ugly by spiritcat on Friday July 06, 2018 @05:04AM (#17469977)
I didn't even know this existed.
Re:Vue.js: the good, the meh, and the ugly by interlocutor on Thursday July 05, 2018 @07:33PM (#17467775)
You can actually leave react and still keep JSX. This tiny library lets you use JSX as a templating mechanism: https://github.com/wisercoder/uibuilder
Re:Vue.js: the good, the meh, and the ugly by smackay on Thursday July 05, 2018 @05:13PM (#17466891)
For me (Vue + Vuex) the choice was simple: you get undo for free.

Having a shared store really does change the way you look at web apps - it's almost a completely different paradigm. If you can avoid re-loading the data for a view if you already have it then then opening a new view to edit a subset of the data instead of dealing with popup makes life so much easier - you get a lot more freedom with the UX and going back to the previous view with the parent data is almost zero-cost.

Re:Vue.js: the good, the meh, and the ugly by ilovecaching on Thursday July 05, 2018 @07:57PM (#17467885)
You can have undo for free using React as well. React doesn't care about how you manage your state changes, and it will selectively render only the parts of your app that changed.
Re:Vue.js: the good, the meh, and the ugly by drb91 on Thursday July 05, 2018 @08:58PM (#17468148)
Not to mention, I believe time travel is an officially supported functionality for redux, if you choose to use that.
Re:Vue.js: the good, the meh, and the ugly by boubiyeah on Friday July 06, 2018 @09:04AM (#17471037)
But now you have a new problem: Managing the freshness of that cache.
Re:Vue.js: the good, the meh, and the ugly by ng12 on Thursday July 05, 2018 @05:39PM (#17467062)
Actually that's my favorite thing about the Redux model.

The vast majority of our codebase is comprised of simple idiomatic React components. Our reducers and glue code (e.g. @connected containers) are a very small portion of the codebase. If I woke up tomorrow and decided Redux was the source of all our problems I could completely remove it while only needing to refactor a small portion (<5%) of our codebase that's mostly boilerplate anyways.

Re:Vue.js: the good, the meh, and the ugly by baddox on Thursday July 05, 2018 @06:24PM (#17467380)
Idiomatic React is both compatible with and orthogonal to state management libraries like Redux or MobX. React is (in my opinion, and likely in the opinion of its creators and maintainers), a library for creating reusable ("dumb" or "presentational") components. In many web apps built with React components, you will want another library to manage the global state of the entire application and provide your dumb components with read/write access to specific pieces of that global state.

I don't understand your point that injecting state into your components (e.g. with Redux' connect function) means JSX is just another fancy HTML templating library. All you need to do is have your React component export a "dumb" version as well as a connected version. Your dumb version will still be reusable in other parts of your application, and any other application could also use your dumb component and connect it to their global state through whatever means they please.

Re:Vue.js: the good, the meh, and the ugly by mrinterweb on Friday July 06, 2018 @01:22AM (#17469071)
I've felt the same way. Vuex, Redux, MobX, or other application state libraries, all help in the event when passing data down through components that don't care about the data they are passing along becomes tedious. I like the general idea of "data down, actions up", but when it comes to separation of concerns, what is the point of a component taking parameters that it is just going to pass to a subcomponent? When components don't use the parameters in a meaningful way, the parameters are just noise. I came to this realization after passing the same parameters down about seven levels deep through components to question the mantra. I try to avoid shared and global state, but there are times that it just becomes very useful. It is important to now and again question if the dogmatic approach is pragmatic.
Re:Vue.js: the good, the meh, and the ugly by spdionis on Friday July 06, 2018 @10:38AM (#17471716)
> seven levels deep

There's your problem I think, as other sibling comments pointed out.

Re:Vue.js: the good, the meh, and the ugly by strken on Thursday July 05, 2018 @05:50PM (#17467157)
React isn't about JSX and passing foo/onUpdateFoo down 20 levels of props. It's about data flowing in one direction down a tree of diffable virtual components, then being passed back up. The single most important idiom is that all data for a component should come from state or props, and that when you need to break this rule you should do it inside a single component or a handful of components that will then handle your global state management.

I understand that such an open-ended product is frustrating to use because redux is insanely overengineered, mobx reintroduces data binding, and context is buggy and terrible, but I don't think what you're calling "idiomatic React" is actually considered idiomatic by anyone, including the core development team.

Re:Vue.js: the good, the meh, and the ugly by chrisco255 on Thursday July 05, 2018 @06:28PM (#17467413)
Redux is not over-engineered. It's a simple library that's <1000 lines of code. It is great for large, complex apps where state gets hairy to manage. It's a bit verbose for smaller apps. But just because something is verbose does not mean it's over-engineered. It is explicit in defining all the possible states your application can get in. That's useful for a certain class of application.
Re:Vue.js: the good, the meh, and the ugly by strken on Thursday July 05, 2018 @07:36PM (#17467794)
It might have been more accurate for me to have said "the code you will get if you follow the reference implementations and documentation of Redux will be overengineered". I dislike three things: that dispatch isn't usually made globally available, but is passed through context, which makes it effectively global anyway; that asynchronous actions are only available via plugins despite being a core part of JS development; and that dispatching an action is just a more complicated way of calling a function.

Interested in hearing what you think, though. My Redux experience has been more limited by trying to avoid it on small projects.

Re:Vue.js: the good, the meh, and the ugly by acemarke on Thursday July 05, 2018 @08:43PM (#17468092)
Hi, I'm a Redux maintainer, and I'd like to clarify a few things.

First, your points about `dispatch` and `context` are specifically about the React-Redux bindings, not the Redux core itself. React-Redux is specifically intended to act as an abstraction layer so that your own components are "unaware" of Redux, which keeps them more reusable and more testable. It also saves you from needing to write store subscription handling every time you want to make use of data from the store. My "Redux Fundamentals" workshop slides [0] show examples of what it would look like to hand-write store subscription code all throughout your UI, and it would be a pain.

If you _really_ want to, there's nothing stopping you from importing the store globally across your application and using it, but that misses out on the benefits of React-Redux, and also ties you to that one specific store instance.

Second, you can absolutely do async logic without any middleware. However, one of the key design points of Redux was to allow users to choose which approach they want to use to handle async logic, without limiting users to whatever was built in to the core. I discussed this in my "Redux Ecosystem" talk at ReactBoston last year [1].

You can certainly do async logic without any special middleware - just `connect()(MyComponent)`, throw in a `setTimeout`, and call `this.props.dispatch()`. The point of `redux-thunk`, the most common async middleware, is that it provides a generic way to move async logic outside of your UI and make it reusable [2].

Finally, the "dispatching an action === calling a function" comparison can be true, but only if you're using Redux with a limited mental approach and treating actions like "setters". If you start thinking about actions as more of an "event that occurred", then that leads to having multiple parts of your reducer logic independently respond to the same action and update their own pieces of state (which is an encouraged usage pattern). Justin Falcone had some good thoughts on this a while back [3], and I talked about this some in a fewmore of my blog posts [4] [5] [6].

[0] https://blog.isquaredsoftware.com/2018/06/redux-fundamentals...

[1] https://blog.isquaredsoftware.com/2017/09/presentation-might...

[2] https://blog.isquaredsoftware.com/presentations/workshops/re...

[3] https://medium.freecodecamp.org/whats-so-great-about-redux-a...

[4] https://blog.isquaredsoftware.com/2017/01/idiomatic-redux-th...

[5] https://blog.isquaredsoftware.com/2017/05/idiomatic-redux-ta...

[6] https://blog.isquaredsoftware.com/2017/01/practical-redux-pa...

Re:Vue.js: the good, the meh, and the ugly by strken on Thursday July 05, 2018 @10:19PM (#17468423)
This is all absolutely true! Redux and React-Redux, and their associated documentation make a lot of intelligent design tradeoffs that have a lot of thought put into them, and that's worthy of respect. "Overengineered" was too strong a term, and I shouldn't have used it. Sorry.

However, some of the things that have been traded are default configuration that represents typical use, standardisation across the ecosystem, and brevity. I think that for a lot of use cases, these tradeoffs make React-Redux harder to use, and that as a whole they make it easier to cause significant architectural problems for a newer or less technical user.

> If you _really_ want to, there's nothing stopping you from importing the store globally

What I've taken to doing is exporting a dispatch function that calls the store's dispatch, not the store. I think this better captures the intention behind Flux than a higher-order component, without much cost, since dynamically swapping between stores doesn't seem common.

> ...one of the key design points of Redux was to allow users to choose which approach they want to use to handle async logic...

This power and choice, while allowing a lot of freedom, comes at the cost of a fragmented ecosystem. The Redux documentation page for async actions lists six different packages that can help.

> the "dispatching an action === calling a function" comparison can be true, but only if you're using Redux with a limited mental approach and treating actions like "setters"

I may not have explained that very well. Actions themselves make perfect sense from the perspective of a reducer, and clearly they must be dispatched, but they're a state management detail that the UI doesn't need to know about. Something similar to redux-action could be the default.

I suppose my core problem with Redux/React-Redux is that I don't understand why a typical component in a typical app doesn't look like

  import { connect } from 'redux'
  import { deleteFoo } from '../actions'
  
  const FooList = ({ foos }) => {
    return foos.map(foo => <button onClick={() => deleteFoo(foo.id)}>Delete {foo.name}</button>)
  }
  
  export default connect(state => ({ foos: state.foos }))(FooList)
Re:Vue.js: the good, the meh, and the ugly by acemarke on Thursday July 05, 2018 @10:29PM (#17468441)
Yeah, for a while it seemed like there was a new Redux side effects lib coming out every week. At this point, though, it's pretty much standardized on thunks for basic use cases, and either sagas or observables for more advanced use cases based on your preference of writing async logic.

> What I've taken to doing is exporting a dispatch function that calls the store's dispatch, not the store.

Not sure I follow that train of thought - could you point to an example?

> Actions themselves make perfect sense from the perspective of a reducer, and clearly they must be dispatched, but they're a state management detail that the UI doesn't need to know about. Something similar to redux-action could be the default.

This is why we recommend use of action creators, so that a component is just calling `this.props.doSomething()` without it "knowing" that a Redux action is actually being dispatched.

Per your snippet there at the end:

- `redux` and `react-redux` are deliberately separate packages, because the Redux core is 100% vanilla JS, and independent from React (in the same way that `react` and `react-dom` are separate packages - the core React logic is independent of the platform-specific reconcilers). So, `import {connect} from "redux"` wouldn't be appropriate.

- The use of `deleteFoo()` that way assumes that it's pre-bound to a specific store instance, which limits the reusability of your logic, and also makes it a lot harder to test. `connect` abstracts away the question of "which store instance am I interacting with?", so that your components and logic are more testable and reusable.

> Something similar to redux-action could be the default.

For what it's worth, earlier this year I threw together a small `redux-starter-kit` package: https://github.com/markerikson/redux-starter-kit . The goal behind it is to simplify some of the most common pain points around Redux: store setup (including thunks and devtools), writing immutable updates in reducers, and having to install multiple packages out of the box. The biggest thing I know it's still missing at this point is indeed something akin to `redux-actions` - see my notes at https://github.com/markerikson/redux-starter-kit/issues/17 .

I haven't had time to push it forward further, but I would seriously like to get some more eyes on it, see if there's any other use cases we should be covering, and then make it an official Redux-branded package and update our docs to recommend that people use it.

Re:Vue.js: the good, the meh, and the ugly by strken on Friday July 06, 2018 @12:55AM (#17468946)
> Not sure I follow that train of thought - could you point to an example?

Something like

  const store = createStore(...)
  export const dispatch = (action) => store.dispatch(action)
It removes the temptation to read directly from the store.

> `redux` and `react-redux` are deliberately separate packages

Yeah, my bad, got the import wrong.

> ...limits the reusability of your logic...

When would this become a problem, in practice? Reusable actions across different react/react-native UI, or multiple apps? Switching between user accounts? How common a use case is it?

Even if this is a constraint, I'm of two minds about whether a hack in isolation is worse than more complicated action boilerplate in general.

> ...and also makes it a lot harder to test...

This can be mitigated by Jest's mocks.

> https://github.com/markerikson/redux-starter-kit

That's really good. Unfortunately, it's not the same thing as bundling it with Redux proper.

Anyway, thanks for engaging with me. I never intended to do a deep dive into Redux's design, only to sympathise with stupidcar's comments about third-party state management, but it's interesting to hear the perspective of a maintainer.

Re:Vue.js: the good, the meh, and the ugly by acemarke on Friday July 06, 2018 @11:02AM (#17471953)
Sure. I'll toss in a few more thoughts here in response.

Your `dispatch` snippet could be simplified to just `const {dispatch} = store`, because the store isn't a class instance - it's a closure. However, I'm not sure why you'd feel a need to "remove the temptation to read directly from the store". In what scenario are you trying to dispatch actions (presumably from the UI), but not read any data?

A basic example of reusability is the unit testing scenario itself. Ideally, you want to minimize the amount of other app code that's getting pulled in, so you can test this one piece in isolation. A React component shouldn't "know" about a store at all - it should just be getting data and functions as props. Similarly, even async logic _should_ be testable in reasonable isolation. If you are directly importing a singleton store instance throughout the entire app, you're coupling all of your logic to that one instance.

Typical testing of store-related logic involves the `redux-mock-store` package, which is just similar enough to a real store to let code run, but records which actions have been dispatched. Similarly, if you do want to test a Redux-connected component and its pieces all together, you would normally provide a unique store or mock store instance there in the unit test - you don't want to drag in the rest of your codebase to test that one piece. (And sure, Jest has some pretty good mocking abilities, but not everyone's using Jest.) I've got some slides on standard Redux unit testing practices [0], and a large section on testing in my React/Redux links list [1].

Outside of testing, yes, reuse of React+Redux across multiple platforms is viable, as is sharing code in libraries. But, again, that only works if the store is effectively dependency-injected at runtime, and that's the point of how things like `connect()`, thunks, and sagas are set up.

I agree that a separate "starter" package isn't the same as putting that all in the core, but that's kind of the point. The starter kit depends on several other packages (`redux-thunk`, `immer`, `selectorator`, etc), while the core Redux library is tiny and standalone. The intent has always been to keep the core small, and let people build pieces on top of it. So, for this package, the specific goal is to help simplify the most common use cases and concerns I've seen, while still avoiding dictating the rest of their app design.

[0] https://blog.isquaredsoftware.com/presentations/workshops/re...

[1] https://github.com/markerikson/react-redux-links/blob/master...

Re:Vue.js: the good, the meh, and the ugly by drb91 on Thursday July 05, 2018 @06:11PM (#17467300)
State management seems like inherently a different problem to solve than the problem React solves. What front-end framework out there has a single state management pattern that works for all sizes?

It’s easy to point out frustrating things or hard problems; it’s not easy to point to a way out.

Personally I love the explicit state flow react forces, and I would hate to move to a framework where I spend time figuring out how data goes from point A to point B.

Re:Vue.js: the good, the meh, and the ugly by pcstl on Friday July 06, 2018 @01:29AM (#17469099)
People mainly use Redux because they don't understand that React isn't Angular. React is meant to care only about UI state. Your application state should be kept separately, and React should just be a function from app state to UI.

Redux is what you get when people try to use React as a "full-app" framework instead of what it's meant to be: a view layer.

Re:Vue.js: the good, the meh, and the ugly by Vinnl on Friday July 06, 2018 @02:41AM (#17469432)
> Your application state should be kept separately,

Is Redux not exactly that?

Re:Vue.js: the good, the meh, and the ugly by pcstl on Friday July 06, 2018 @03:47AM (#17469713)
It can be used for that, but it quickly becomes cumbersome. Redux, in my opinion, should be used for complex UI state in applications with complex interfaces where interactions with one part of the UI can change very different parts ("spooky action at a distance", so to say). But it shouldn't be used to keep all your application's state.

Your application's state should live outside of React, and be passed in as the root's props.

Re:Vue.js: the good, the meh, and the ugly by Vinnl on Friday July 06, 2018 @06:13AM (#17470228)
I agree w.r.t. what you should Redux for. That said, if you store application state in Redux, is that nout "outside of React", passing it in as props? (Though not necessarily the root's props.)
Re:Vue.js: the good, the meh, and the ugly by d0100 on Friday July 06, 2018 @04:59PM (#17475053)
I think the opposite.

Redux should have your application state, and any UI state should be in pure React (portals, context, etc).

Redux -> app data React -> UI

Re:Vue.js: the good, the meh, and the ugly by shados on Friday July 06, 2018 @11:25AM (#17472164)
> People mainly use Redux because they don't understand that React isn't Angular

Ironically, Redux came out around the time Angular popped. While not everyone, a significant portion of early adopters came in because they were rejecting the Angular 1.X way of handling state, and Redux was the polar opposite.

Re:Vue.js: the good, the meh, and the ugly by WA on Friday July 06, 2018 @01:40AM (#17469145)
So how do you manage your application state? I‘m curious, because a search for such a phrase always brings up Redux, Thunks and Saga.
Re:Vue.js: the good, the meh, and the ugly by pcstl on Friday July 06, 2018 @03:48AM (#17469717)
You keep it out of React, manage it however you want to and is most convenient for your application's data model, and pass in the parts that are relevant to UI as props to React's root.
Re:Vue.js: the good, the meh, and the ugly by kalkut on Friday July 06, 2018 @04:36AM (#17469875)
You can make any suitable variation of the following pattern.

You build a DataSource class/prototype with methods such as :

- fetch

- addChangeListener

- removeChangeListener

You extend this class for each data type :

  class CommentsData extends DataSource {
    // Your custom data source with your data treatment and data getters
  }
And you use the Higher-Order Component pattern: https://reactjs.org/docs/higher-order-components.html
Re:Vue.js: the good, the meh, and the ugly by boubiyeah on Friday July 06, 2018 @09:14AM (#17471099)
That's just a more Object Oriented Redux (or less, if we consider OOP is originally message passing), and probably without all the connect optimizations.

I'm not a fan of Redux either, but I fail to see what problems this approach solves.

Re:Vue.js: the good, the meh, and the ugly by kalkut on Friday July 06, 2018 @02:54PM (#17474160)
> That's just a more Object Oriented Redux

> I fail to see what problems this approach solves.

You are absolutely right I gave an ad-hoc Redux as an example of Higher-Order Component.

Being OOP or not is only a matter of implementation of your data source. Here you have absolute control on it and depending on the type of your data, the frequency at which it is updated or its (a)synchronicity, you may prefer/need something very different from a dispatcher/action/reducer system.

The real pattern here is the HCO and yes Redux also use this pattern to build "smart components" with "dumb" ones. But it does it in a very opinionated way.

As an example : for performance reasons you really don't want Redux to handle real-time data with very frequent updates, it is better to manage this kind of data your own way.

A more common case is having only a few amount of data that have to be shared across the tree (things like an user session or the chosen language). If your component tree has too many level of depth an ad-hoc solution can do fine here.

IMHO there is two type of arguments for why Redux might not be needed :

1) A reasonable UI respects separation of concerns.

There should be limited need for data exchanges or interactions between two unrelated components. Making the data flow from the local state of a "smart component" is fine most of the time.

2) What Redux does can be done with less boilerplate when and where it is needed.

You can make your component "smart" in a lot of ways. It can be done with pure React state management, it can be done with custom data sources and HCO, it can be done with JavaScript CustomEvents and so on.

The worst problem here is that because Redux is a (very good) opinionated abstraction, lots of developers forget it is a library and not a framework so they try to find what they think is the most Redux-way of doing things. I've seen tons of projects that ended up being a mess of Redux/Thunk/Reselect plus whatever middlewares where updating a single property implies at least handling it in the reducer, adding a selector, and adding the result in mapStateToProps. Redux is definitely not a bad solution but in becoming a standard one it hurt a lot of projects.

This situation is very well explained by pcstl above when he says

> People mainly use Redux because they don't understand that React isn't Angular.

> Redux is what you get when people try to use React as a "full-app" framework instead of what it's meant to be: a view layer.

Re:Vue.js: the good, the meh, and the ugly by mosdl on Friday July 06, 2018 @11:58AM (#17472461)
What connect optimizations? Redux is quite slow.
Re:Vue.js: the good, the meh, and the ugly by acemarke on Friday July 06, 2018 @12:22PM (#17472660)
`connect` does a _lot_ of work to ensure that your own components only re-render when necessary:

- It checks to see if the root Redux state is different than last time, and bails out if it's the same reference under the assumption that nothing changed

- It checks to see if the return values from your `mapState` function are shallow-equality different than last time, and again bails out if they're the same

- The handling for `mapState` and `mapDispatch` is heavily memoized to cut down on unneeded work.

If you have specific performance concerns with a Redux app, please let me know - I'd be happy to offer advice and point you to possible solutions. But, a blanket statement that "Redux is quite slow" is meaningless without context for what's happening.

Re:Vue.js: the good, the meh, and the ugly by mosdl on Friday July 06, 2018 @02:17PM (#17473820)
In large apps mapStateToProps gets called when things my component doesn't care about change - its a simple downside to having one global store as a design.

We now speed things up buy removing redux and just using events with multiple stores anyone can access - we can easily tune the system and don't have to rely on magic that can never be as efficient. Plus the syntax is much cleaner.

Re:Vue.js: the good, the meh, and the ugly by kalkut on Friday July 06, 2018 @03:15PM (#17474305)
Dispatch is another big culprit.

I have exactly the same experience and implemented the same solution. An ex-colleague also did the same thing. We both worked on collaborative webapps but in different companies at the time so performance gain was very important.

I still use Redux on some projects but I definitely start the new ones without thinking about it.

Re:Vue.js: the good, the meh, and the ugly by acemarke on Friday July 06, 2018 @04:00PM (#17474638)
> Dispatch is another big culprit.

Could you clarify what you mean by that?

Per both of your comments: generally speaking, your `mapState` functions _should_ run as quickly as possible. Ideally, a `mapState` function should just grab a couple values from the Redux state object and return those.

If a component needs the store data to be transformed in some way, we recommend using memoized selector functions [0] to cut down on unnecessary work.

So, in a well-written app, your `mapState` functions shouldn't be bottlenecks.

As I said, if you've got some examples of specific perf issues, I'd be happy to offer advice.

[0] https://blog.isquaredsoftware.com/2017/12/idiomatic-redux-us...

Re:Vue.js: the good, the meh, and the ugly by kalkut on Friday July 06, 2018 @05:09PM (#17475140)
> Could you clarify what you mean by that?

A call to dispatch is significantly more expensive than the update of a JS object

> Ideally, a `mapState` function should just grab a couple values from the Redux state object and return those.

Ideally it should, but in practice it is really much more expensive than getting a value in a JS object

> If a component needs the store data to be transformed in some way, we recommend using memoized selector functions [0] to cut down on unnecessary work.

I used Reselect before removing Redux. Beyond the fact that it adds a lot of boilerplate it does not help if you do need a lot of data updates.

> So, in a well-written app, your `mapState` functions shouldn't be bottlenecks.

It shouldn't but a few dozen of updates per second through Redux on a mobile take a toll on its performance serious enough to not be able to keep 60fps in a WebGL context.

I decided to remove Redux after noticing the performance overhead per function call in the Chrome performance profiler, so I know that in practice "dispatch" and "mapState" are not comparable to just editing or grabbing "a couple values from the Redux state"

My ex-coworker had the same issues because he needed to display a lot of items handled collaboratively with smartphones. In both of our cases we have a high rate of data updates, even if we optimize like crazy we are never going to fall under 4-5 update/second per connected user.

So yeah Redux can run well for webapps with a slow/regular pace of update but for more performance sensitive apps you do pay a Redux performance tax.

Again I still use Redux on some projects and I like it but the limits are there. So now I don't hesitate to do without it first and to use it when I need its abstraction.

Re:Vue.js: the good, the meh, and the ugly by acemarke on Friday July 06, 2018 @05:33PM (#17475303)
Hmm. Could you maybe file an issue on the React-Redux repo and provide some repro examples for your use case? I'd be interested in seeing the perf traces myself. This would also be valuable as we work on refactoring React-Redux to work with the new React context API. I have a hunch that my proposed architecture will improve perf, but having more benchmarks would be helpful.
Re:Vue.js: the good, the meh, and the ugly by kalkut on Friday July 06, 2018 @07:22PM (#17475860)
You really are helpful and you try to fix this so I really want to say yes but I am currently grinding for my own startup so I know that a lot of time will pass before I actually do it so I don't promise anything.

A good way to test it would be to make a simple websocket server that simulate n users each sending n' fake xyz position and rotation data per second. This data updates a Redux store in a React app made with Aframe (HTML wrapper around ThreeJS). You make n cubes move and rotate along the data in the store. Compare the fps you get against the fps you get with a vanilla solution. Also check what happens on the performance tab of chrome

I am able to recognize that my use case is very specific. I used React/Redux/Reselect and Aframe/ThreeJS with sockets a year ago. Now I kept React but the rest of the stack have changed for nearly a year

Re:Vue.js: the good, the meh, and the ugly by acemarke on Friday July 06, 2018 @10:07PM (#17476471)
Gotcha. I've made a note of this in https://github.com/reactjs/react-redux/pull/898 for future reference.

If you ever do have some free time to throw together an example app that demonstrates this behavior, please feel free to link it in that issue, or ping me directly (Twitter and Reactiflux are usually best).

Re:Vue.js: the good, the meh, and the ugly by kalkut on Saturday July 07, 2018 @09:15AM (#17478365)
I ended up hacking a benchmark. I couldn't beat that itch !

I mentioned it in the pull request, here it is : https://github.com/Kalkut/redux-data-frequency-benchmark

Re:Vue.js: the good, the meh, and the ugly by mosdl on Friday July 06, 2018 @04:20PM (#17474795)
The problem is that they run too often, not that they are slow. mapStateToProps is called too often, and that leads to a bunch of needless shallow compares and often renders. Its a weakness of the magic design, and if I need to optimize the magic might as well just implement the whole thing.
Re:Vue.js: the good, the meh, and the ugly by aylmao on Thursday July 05, 2018 @05:39PM (#17467060)
> as soon as you're in the real world, you hit its limitations very quickly.

Isn't a good chunk of AirBnB, Facebook, Instagram, Netflix, The New York Times and Dropbox written in React?

The built-in state management has limitations, of course. I see it best for keeping state relevant to display-- React is supposed to be a "view" library, not a state management one.

Re:Vue.js: the good, the meh, and the ugly by heyoni on Friday July 06, 2018 @07:32AM (#17470558)
Is there a way to tell or are we going by what these companies disclose?
Re:Vue.js: the good, the meh, and the ugly by shados on Friday July 06, 2018 @11:26AM (#17472176)
Use the react devtools when looking at those websites.
Re:Vue.js: the good, the meh, and the ugly by mateuszf on Friday July 06, 2018 @03:13AM (#17469565)
And also Office 356
Re:Vue.js: the good, the meh, and the ugly by Too on Saturday July 07, 2018 @03:31AM (#17477523)
Both Airbnb and O365 web apps are horribly slow in the browser and hasn't had any noticeable feature growth in the past 4 years so i wouldn't use these as good examples of neither performance nor productivity.
Re:Vue.js: the good, the meh, and the ugly by tomaskafka on Friday July 06, 2018 @08:59AM (#17471006)
> If plain, idiomatic React so great, why does every semi-complex React app end up bringing in a separate state management framework like Redux or MobX?

Because React = state to DOM while Redux = how to get from previous state + action to a next state? :)

They do different things.

Re:Vue.js: the good, the meh, and the ugly by tanilama on Friday July 06, 2018 @02:17AM (#17469341)
Because async state management is a pain, and hard to reason about, that is what Redux and MobX are for.
Re:Vue.js: the good, the meh, and the ugly by wehere1111 on Friday July 06, 2018 @11:05AM (#17471980)
if walking is so great, why does every semi-long distance end up requiring a car or bicycle?