News for hackers. Stuff that matters.
Re:Thinking in React Hooks by oaxacaoaxaca on Thursday December 12, 2019 @01:02PM (#21774401)
I have not been a fan of hooks thus far, but these are some intriguing examples. Especially the useMemo ones.

My complaints about hooks are that with hooks we lose useful tools in our react toolkit: class methods, separate componentDidMount/componentDidUpdate lifecycle events, shouldComponentUpdate, PureComponent, etc.

And my biggest complaint is that we're losing simplicity. React spread like wildfire when it first came out because it was so beautifully simple: a class, with something called `props`, and this.state and this.setState(). That's it. You can build SO MUCH with just that.

To me, with hooks, React's simplicity is being replaced by cloudiness. There's so much "magic" now. The order of hooks in the code is the most important thing for a hook component to work right. New linter rules had to be built to remind people where hooks need to be written.

I do appreciate the work that's been put into hooks. And like any other open source project, I'm incredibly grateful to the authors and maintainers. I guess I just wonder if anyone shares the same sentiments as mine, because it seems like the only thing I read about this topic is that classes suck, class components are full of pitfalls, etc.

Re:Thinking in React Hooks by lilactown on Thursday December 12, 2019 @01:24PM (#21774648)
You use the word "simple," but it sounds like you mean something more like "familiar." That's not a knock; familiarity is important when designing an API that thousands of developers are going to use every day.

But as you can see by the blog post, there are tradeoffs between doing something the way people are familiar with, versus a different way that's less familiar, but has different capabilities that might fit the problems better.

Classes map to certain use cases very well; for instance, there's no Hook for "componentDidCatch" or any other error handling.

That being said, you are not losing anything. The tools are simply different (although the old tools are still there, too!).

As the blog post goes into, you can still implement the same _behavior_ as you did with componentDidMount/componentDidUpdate, but with Hooks you can formalize the different patterns you would find when using those methods into a custom hook that you can reuse. This wasn't possible before.

shouldComponentUpdate can be easily replaced with React.memo, a higher-order component that takes a function that compares the previous props to the new props and returns whether they are the same. Wrapping it in React.memo without a custom comparator is the same as PureComponent.

Re:Thinking in React Hooks by oaxacaoaxaca on Thursday December 12, 2019 @02:44PM (#21775555)
> You use the word "simple," but it sounds like you mean something more like "familiar."

Guilty as charged. I needed to hear that :)

Re:Thinking in React Hooks by westoncb on Thursday December 12, 2019 @05:55PM (#21777514)
To play devil's advocate a bit: I don't think you were wrong the first time.

I mean, as long as hooks are strictly an addition, it's easy to argue greater simplicity without. That's kind of trivial though, so I would ask how thematically related they are.

If they both clearly stem from the same set of underlying principles and motivations, I think it's fair to say the addition is not substantially a complication. But is that the case for hooks? (I don't know—haven't looked into them yet :)

But maybe the confusion is whether the additional complexity we're talking about is in React itself, or in the systems being built with react. In that case, old React may be simpler, but the code it produced was more complicated; or React with hooks may be more complicated, but the code you write with it is now simpler.

Re:Thinking in React Hooks by Izkata on Thursday December 12, 2019 @09:44PM (#21778729)
I'd argue it's more complicated by way of how much confusion I see with newbies. The old class-based lifecycle+methods was pretty straightforward - it only looked complicated at a glance. Hooks on the other hand do enough magic in the background that each one seems to come with its own set of misconceptions that have to be corrected.
Re:Thinking in React Hooks by BigJono on Thursday December 12, 2019 @10:09PM (#21778841)
The ironic thing is that hooks are marketed by the react docs as being the solution to avoiding the "difficulty" newbs have with classes.

Which I (as a proponent of hooks) think is fucking batshit insane, and clearly shows the disconnect of the React devs from their user base.

Teaching beginners how to code, and how to use React, is a large part of my job. And I can say with absolute conviction that the React team is wrong about this. The 'hooks' whiteboarding session has gotten me far more blank stares than the 'classes and lifecycles' one ever has.

Having said that, as a senior dev with a ton of React projects under my belt, I definitely prefer the hooks paradigm after using it in a few projects. It makes for cleaner code, and certain concepts are much easier to reason about with the hooks model. Just don't ever expect it to give you a cleaner on-boarding process. That's not at all where the benefit lies, despite what the docs tell you.

Re:Thinking in React Hooks by Izkata on Thursday December 12, 2019 @10:12PM (#21778855)
Should probably dump it here myself: My experience is mainly with co-workers (years of experience) and new hires (just out of college/bootcamp) who can code, but haven't yet used React.
Re:Thinking in React Hooks by BigJono on Thursday December 12, 2019 @10:54PM (#21779029)
Yeah my experience is pretty much all with beginners (usually fresh out of a bootcamp or college, or switching from tangentially related industries like CSE).

I'd be interested to see how someone who was a beginner but learnt via FP would grasp each approach. I've never met one in the wild though, it's not like bootcamps start with Haskell.

Re:Thinking in React Hooks by erikpukinskis on Friday December 13, 2019 @02:27AM (#21779781)
Are they a strict addition? I never learned class-based components. I literally never think about “mounting”.

I also never think about “updates”. I do think about rendering as something that happens continuously all the time outside my control.

Re:Thinking in React Hooks by dkarl on Thursday December 12, 2019 @06:09PM (#21777614)
I think the old way is simpler in the sense of building on fewer concepts, and therefore allowing an easier learning curve, if you grant that understanding the React component lifecycle is required and inevitable. Once you understand the lifecycle, running code when certain lifecycle events happen is a very small, concrete conceptual leap. Names like "componentDidMount" tie directly into your fundamental understanding of React. If using them to maintain state forces you to deepen your understanding of the component lifecycle, that effort will pay dividends when you have to debug, optimize, understand someone else's wacky code, etc.

Hooks, on the other hand, have to be learned as an additional and separate concept. In fact, each hook has to be learned. You won't have a clue what "useState" and "useEffect" do just by having a knowledge of React fundamentals. If using hooks allowed developers to avoid knowing the React component lifecycle, an argument could be made that they provide a simpler alternative, but I don't think anybody is going to get very far without being forced to learn about the component lifecycle. If someone were to say, "The React lifecycle is hard to understand, so use hooks instead," that would be a false promise. Hooks are something extra to learn, not an alternative to understanding the lifecycle. To the extent that a programmer can avoid understanding the lifecycle by using hooks instead, they are just putting off that learning curve until they have to traverse it later, probably under the pressure of debugging some nasty issue.

Hooks seem to win from another perspective, though, which is that by accepting the cost of adding this new concept to your mental model, you can write simpler-looking code that is easier to keep error-free. To me, that's the trade-off. Hooks are an extra complexity to understand, and each new hook can encapsulate arbitrary complexity and behavior that isn't obvious from reading code that uses them, but the code that uses them can be more concise and perhaps easier to read and keep correct.

Re:Thinking in React Hooks by ratww on Thursday December 12, 2019 @08:16PM (#21778272)
I think this also falls into the same familiarity trap as the parent.

Let me preface this by saying that I think it's not necessary to conflate the "lifecycle methods" with the component lifecycle in itself, and I disagree with the premise that the methods are a fundamental concept of React. Of course, this is how people were historically taught, but it is entirely possible to conceptualise and understand the lifecycle of a React component without even knowing about lifecycle methods, just in terms of how useEffect works, for instance, and this is how a lot of people using hooks today think. It is entirely possible to understand how re-renderings are triggered and stuff like that without even knowing about class components and lifecycle methods.

So, hooks might seem like an additional concept to people used to class components and lifecycle methods, but that's just because of familiarity. For people learning hooks first, the opposite is true just as well.

IMO this paradigm shift in thinking is also essential for people used to class components that want to be more productive in codebases with mostly hooks. I haven't thought about componentDidUpdate and friends in months.

Re:Thinking in React Hooks by pandler on Friday December 13, 2019 @12:40AM (#21779374)
> I think the old way is simpler in the sense of building on fewer concepts, and therefore allowing an easier learning curve

I would disagree with that premise. From my own experience and from having mentored developers on class components (so like ~7 data points), I'd say it's far easier to reason about state flow with hooks than lifecycle methods. That's an important point, because I see far more bugs with incorrect or incomplete state flow than I see with component lifecycles.

Hooks are simply easier to reason about. With hooks, you read the code top to bottom. Then, something changes either with the data or in response to user input, and then you read the code top to bottom again with that new state.

The only learning curve there is to understanding the basic premise of hooks is that "if this value is different from the last time you read the code top-to-bottom, then re-read/execute this code block"

> If using hooks allowed developers to avoid knowing the React component lifecycle, an argument could be made that they provide a simpler alternative, but I don't think anybody is going to get very far without being forced to learn about the component lifecycle. If someone were to say, "The React lifecycle is hard to understand, so use hooks instead," that would be a false promise.

That is exactly my premise, and I don't think it's a false one. Since moving to hooks, I can't remember the last time I had to care about the React lifecycle. Again, the mental model is "Read the code top to bottom; something changes; read the code from top to bottom" ad infinitum.

Yes there are situations where class components provide more intimate control (componentWillUnmount comes to mind since I'm not aware of a hook for that), but are we really optimizing the majority of our code for exceptional cases?

Another data point: I haven't seen functional components turn into a complete mess from inattentive developers in the same way I've seen class components turn into indecipherable setState tangled messes. The only time I've experienced the pressure of sifting through component lifecycles under the pressure of debugging a time-sensitive production isssue is because I was using component lifecycles in the first place. It's a moot point.

Re:Thinking in React Hooks by cmwelsh on Saturday December 14, 2019 @09:42PM (#21794109)
> Yes there are situations where class components provide more intimate control (componentWillUnmount comes to mind since I'm not aware of a hook for that), but are we really optimizing the majority of our code for exceptional cases?

The return value of invoking React.useEffect’s first parameter is a cleanup function which serves this purpose.

Everyone in this thread is ragging on core concepts like useMemo or useEffect. Once you know these core functions, you’ve learned all the magic. Then you can write spells of your own.

Re:Thinking in React Hooks by lhorie on Thursday December 12, 2019 @03:33PM (#21776107)
I think the argument that hooks lose on simplicity (as opposed to familiarity) can hold water if you think about it this way: sure procedural code is very familiar to most JS devs and consuming hooks indeed feels procedural. Ok. BUT. Reasoning about the rules of hooks when you're writing non-trivial hooks, that's not familiar, and it's not simple either. At my day job, there have been some debates about supporting Suspense composition and the semantics are very difficult to reason about because not only you have to keep in your head what the procedural code actually does, but you also need to keep track of whether e.g. certain flavors of certain expressions violate the rule of hooks. The term "magic" is a very appropriate way of describing how hooks feel in this context.
Re:Thinking in React Hooks by chrisweekly on Thursday December 12, 2019 @07:17PM (#21777961)
Thanks for sharing. As someone who's done React for years (and webdev since 1998) but yet to do more w/ Suspense than read about it, it seems to me like [Suspense + Hooks] is an area where we're still some distance from solid idioms and established best practices. Maybe the APIs will undergo further refinement before that happens. As for magic (which, if good, decomposes into sane primitives), you might be right. But in general I appreciate the degree to which React's evolution over time has trended towards reducing the cognitive overhead of lifecycle concerns and state mgmt solutions. (To say nothing of reconciliation, which I'm perfectly happy to enjoy, whether it's voodoo or not.) /ramble
Re:Thinking in React Hooks by Klonoar on Thursday December 12, 2019 @03:11PM (#21775851)
>Classes map to certain use cases very well; for instance, there's no Hook for "componentDidCatch" or any other error handling.

>That being said, you are not losing anything. The tools are simply different (although the old tools are still there, too!).

Well... no, you clearly are losing something. You might not use it frequently but it's a pain in the ass when you do need it.

Re:Thinking in React Hooks by lilactown on Thursday December 12, 2019 @04:18PM (#21776587)
Classes are not verboten :) I typically create an error boundary that wraps my app/feature/etc. with a fallback component and call it a day.
Re:Thinking in React Hooks by kqr on Friday December 13, 2019 @12:47AM (#21779391)
> familiarity is important when designing an API that thousands of developers are going to use every day.

I'd argue it's less important for an API people use every day than it is for an API used once a month. Things should be designed for people with more than one week of experience with it, even if it makes adoption slightly tougher!

Re:Thinking in React Hooks by stickfigure on Thursday December 12, 2019 @02:02PM (#21775058)
My initial impression was similar to yours, but after I started using hooks, my opinion changed 180 degrees. I've been slowly converting a rather large React frontend to hooks and it solves so many problems.

We used to fetch data with HOCs. That never worked well with typescript and was a big problem when you wanted to use more than one (ie, fetching multiple data sources). With hooks we just add separate hooks for each data source we fetch... and the hooks themselves are much simpler than HOCs.

Like the article mentions, hooks move up a layer of abstraction. I'm purging my brain of all the nitty gritty detail of React component lifecycles, because all I ever really cared about was getting data to update at the right time. And now that's the level I can operate at.

Yeah, it doesn't look like standard object oriented code that we're used to. Maybe they could have chosen a different syntax, dunno. But after you get used to hooks, the grass definitely is greener.

Re:Thinking in React Hooks by acemarke on Thursday December 12, 2019 @02:42PM (#21775519)
Hooks definitely bring a different set of tradeoffs, especially compared to Higher Order Components. I'm a Redux maintainer, and the React-Redux API is a good example of this. The `useSelector` and `useDispatch` hooks are way easier to statically type than `connect` is, but calling those hooks embeds knowledge of Redux directly into the component instead of separating it.

I specifically talked about these differences in my post "Thoughts on React Hooks, Redux, and Separation of Concerns" [0] and my ReactBoston 2019 talk on "Hooks, HOCs, and Tradeoffs" [1].

For myself personally, I've completely switched to writing function components as a standard practice, but we've also got a lot of devs who are newer to React and still writing classes. I don't feel a need to force rewriting all of those to function components, although I will probably find some time to let folks know that function components + hooks are a thing.

[0] https://blog.isquaredsoftware.com/2019/07/blogged-answers-th...

[1] https://blog.isquaredsoftware.com/2019/09/presentation-hooks...

Re:Thinking in React Hooks by wilsonrocks on Thursday December 12, 2019 @03:15PM (#21775910)
Totally agree about useState and useDispatch... So much easier! It is true that it beds knowledge in the component, but how likely am I to replace redux in a working app?
Re:Thinking in React Hooks by nsenifty on Thursday December 12, 2019 @04:30PM (#21776718)
Additionally, you can write your own hooks that invoke redux hooks internally and hence provide reusability and separation of concerns.
Re:Thinking in React Hooks by modwest on Thursday December 12, 2019 @02:36PM (#21775449)
I'm there exactly with you. I could've written this comment myself. Love hooks so much. Excellent abstraction.

edit: i guess i'm just supposed to upvote and move on but i'm enthusiastic about this topic :)

Re:Thinking in React Hooks by ratww on Thursday December 12, 2019 @02:10PM (#21775150)
Separate methods for lifecycle events is probably the biggest weakness of class components. They work well for smaller components, but when you have multiple things going on in a single class you have code related to a single concern scattered around multiple methods, and you start having to use conditionals inside your lifecycle methods.

The article doesn't show pathological cases using classes, but with hooks it becomes possible to extract complex behaviors involving different lifecycles much more cleanly.

I recently migrated a large React project to use hooks and a lot of repetitive code with lots of repeated patterns (especially things related to data access) is now much more cleaner. Now I can just have something like `useFetch` instead of ten lines of code that I needed just because I was using lifecycle methods.

And the fact that the order of hooks matter is what makes them so easy to abstract. Having them store their own "id" would remove the need for that rule, but then you'd be running at other kinds of bugs.

Re:Thinking in React Hooks by axbytg on Thursday December 12, 2019 @01:35PM (#21774743)
I would totally disagree. We started migrating our front end to React this year. We dipped our toes in with Class based components, found out about hooks, and never looked back. Hooks are confusing when you're trying to translate a class based component to a functional component with hooks. Starting a component or page from the ground up with hooks is so, so much simpler than class based components. As with any iteration of any framework, there are gotchas, but they are no worse than Class based react (totally opinion there). The mental model, once you latch on to it, is so simple.
Re:Thinking in React Hooks by ArchReaper on Thursday December 12, 2019 @04:01PM (#21776410)
After using hooks for a while, I have to disagree with most of your points. The issue is not clarity or simplicity, it's familiarity. Once you start actually using hooks, things make a ton of sense. It's a different way to think about components, not an inherently more-complex way.

The order of hooks is only important insofar as they do not change between rendering. That's it. Hooks should always be called, and always in the same order.

A basic React Hooks component has way less boilerplate involved than a class component does, and hooks allow for much better code architecture when it comes to separation of concerns.

Re:Thinking in React Hooks by atombender on Thursday December 12, 2019 @02:57PM (#21775694)
I have the opposite view. The things you mentioned (componentDidMount, etc.) are actually hard to get right, and class-based components don't help by scattering the logic all over the place.

Functional components force your component lifecycle into a funnel where the lifecycle becomes obvious, because all the inter-dependencies are already there.

For componentDidMount, you can replicate this easily with hooks:

  const Hello = () => {
    const mounted = useRef(false)
    useEffect(() => {
      if (!mounted.current) {
        mounted.current = true
        console.log("Mounted!");
      }
    }, [])
    return <>Hello</>
  }
Extracting anything into a hook is trivial:

  function useMounted(f) {
    const mounted = useRef(false)
    useEffect(() => {
      if (!mounted.current) {
        mounted.current = true
        f()
      }
    }, [])
  }

  const Hello = () => {
    useMounted(() => {
      console.log("Mounted!");
    })
    return <>Hello</>
  }
Implementing an unmount callback is also trivial.

The useMounted() example, coincidentally, shows a real benefit to hooks: Easy extraction of reusable logic. Hooks are like plugins this way. For example, one hook I've written that I use all the time is this [1], it lets you get a callback every time your component resizes. If you were to do this with a class-based component, you'd have to use an ugly HOC, which results in lots of unnecessary wrapping/nesting.

For componentDidUpdate, useMemo() is arguably easier to deal with.

[1] https://gist.github.com/atombender/b95bbd2014f6a3ec303b843a9...

Re:Thinking in React Hooks by ArchReaper on Thursday December 12, 2019 @04:11PM (#21776521)
Unless I'm missing something, you don't need all that just to have 'componentDidMount' eg:

    export const useMounted = (f) => {
      useEffect(f, []);
    }
Edit: originally:

    export const useMounted = (f) => {
      useEffect(() => {
        f();
      }, []);
    }
Re:Thinking in React Hooks by atombender on Thursday December 12, 2019 @04:22PM (#21776628)
Ah, of course. The use of dependency lists in React is something I keep forgetting exist. Thanks.
Re:Thinking in React Hooks by acemarke on Thursday December 12, 2019 @04:12PM (#21776524)
And to code-golf it a bit further, it can just be:

    useEffect(f, [])
Re:Thinking in React Hooks by city41 on Thursday December 12, 2019 @02:02PM (#21775065)
PureComponent is reproducible with React.memo(functionComponent)

My main complaint with hooks is people seem to think they always need them. I've seem components where every single piece of data, no matter how trivial, is slapped into a useMemo(). It becomes a lot of mental overhead to trace through them all, especially confirming the useMemos have the correct dependencies specified. Especially when the vast majority of the time, useMemo just isn't needed.

Re:Thinking in React Hooks by erikpukinskis on Friday December 13, 2019 @02:40AM (#21779812)
> My main complaint with hooks is people seem to think they always need them

The low level problem here is your team doesn’t realize that every word of code means something.

You need to get past the idea that code has to be there to do a thing and get to the place where you expect every bit of code to explain something.

“Why is there a useMemo here”... if your team can’t explain that, then “changes requested”.

Re:Thinking in React Hooks by ratww on Thursday December 12, 2019 @02:16PM (#21775231)
That's a very common anti-pattern. :(

I've seen a lot of cases in the wild where useMemo was used to wrap closures, "for performance reasons", but that's obviously more wasteful than just using the closure by itself. I think a lot of people don't realize that.

Re:Thinking in React Hooks by RussianCow on Thursday December 12, 2019 @03:48PM (#21776267)
To be fair, if you're passing the closure to a component that extends PureComponent or is wrapped by React.memo, then memoizing the closure will ensure you take advantage of that optimization in the child; otherwise, you're passing a branch new function reference on every render, which means the child is needlessly re-rendering. At work, we have many components that are very complex but take a limited set of props, so these kinds of optimizations are absolutely vital for good performance.

That said, you're correct in that this should be the exception and not the rule. It's pointless to do this for a component that returns a single element, as the virtual DOM reconciliation will be much faster than the memoization + props comparison.

Re:Thinking in React Hooks by erikpukinskis on Friday December 13, 2019 @02:42AM (#21779827)
If you have limited props, why would your component be rendering often?
Re:Thinking in React Hooks by RussianCow on Friday December 13, 2019 @11:27AM (#21782967)
Because the parent might render often.
Re:Thinking in React Hooks by erikpukinskis on Friday December 13, 2019 @03:28PM (#21785113)
That shouldn’t cause the child to re-render?
Re:Thinking in React Hooks by RussianCow on Friday December 13, 2019 @07:56PM (#21787046)
I'm not sure why you think it wouldn't. Any time a component renders, React also renders all of its children except the ones for which shouldComponentUpdate returns false. If that is defined by using PureComponent or React.memo on a child, then you have to make sure that the props you pass in are not going to change on every re-render (i.e. you can't pass an un-memoized callback because a new function reference will be created on every render).

I've created a CodePen to illustrate: https://codepen.io/RussianCow/pen/xxbERLL

Open the console and watch as the "render child" message is logged once per second, showing that the child is re-rendered every time the parent is.

Re:Thinking in React Hooks by fengb on Thursday December 12, 2019 @01:57PM (#21775003)
Lifecycles map closer to how the underlying UI layer works, but not to developer expectations. I've lost countless hours to desynced implementations such as failing to account for componentDidUpdate when overriding componentDidMount or missing a corresponding componentWillUnmount cleanup.
Re:Thinking in React Hooks by baddox on Thursday December 12, 2019 @01:48PM (#21774916)
I’m genuinely wondering why the fact that the order of hooks needs to stay the same between successive invocations of your function component is considered a bad or confusing thing. The complaint comes up a lot, so I know that it bothers people, but I haven’t been able to understand why.
Re:Thinking in React Hooks by ratww on Thursday December 12, 2019 @02:26PM (#21775341)
I can sympathize with people that find it confusing, because it is an unusual requirement considering they're simple function calls. The fact that the only way to implement them (that I can think of) is messing with global state is also a very strange in today's functional-centric programming world.

But on the other hand I agree that "keep the order!" is a very simple request for a feature that is so useful.

Re:Thinking in React Hooks by erikpukinskis on Friday December 13, 2019 @02:43AM (#21779832)
> the only way to implement them (that I can think of) is messing with global state

What do you mean?

Re:Thinking in React Hooks by ratww on Friday December 13, 2019 @07:08AM (#21780878)
A regular global variable that is incremented each time you call useState/useEffect/etc and is resetted every time a new component starts rendering. This is why hook order must be maintained.

I have no idea where this is implemented in React, but in Preact it's a simple integer that is incremented:

https://github.com/preactjs/preact/blob/abc162c4d6442d5495f6...

I think there are other ways to implement them, such as treating the return of the render function as an AST and turning hooks into dumb factories, like a free monad. But considering the constraints they have (the need to maintain order) and the way it works (the fact the render function runs multiple times), I'm guessing it's just the same solution as Preact.

Re:Thinking in React Hooks by brlewis on Friday December 13, 2019 @01:06PM (#21783847)
Resetting it as render starts makes that number conceptually local to the vnode, even though preact's implementation involves a variable that's global in the context of that module.
Re:Thinking in React Hooks by paulddraper on Thursday December 12, 2019 @05:35PM (#21777317)
The most probable case of an issue is putting then inside a conditional block.
Re:Thinking in React Hooks by erikpukinskis on Friday December 13, 2019 @02:45AM (#21779841)
Just put the conditional inside the hook.
Re:Thinking in React Hooks by JMTQp8lwXL on Thursday December 12, 2019 @01:48PM (#21774915)
You don't have to use hooks and class declaration syntax is not going away. If you don't like a paradigm, you don't have to use it. I was quite skeptical of hooks at first, but after using them for a bit, they grew on me. It is not as simple as the class-based approach, but I also haven't found it to be a giant mental leap: my "warming up" to hooks took about a week.
Re:Thinking in React Hooks by k__ on Thursday December 12, 2019 @01:55PM (#21774977)
Funny that you mention separate class methods for lifecycle stuff. Because hooks were created to solve the problem that this separation brought.
Re:Thinking in React Hooks by deviantfero on Thursday December 12, 2019 @06:26PM (#21777659)
I've just used hooks for the first time, I'd been working with react for three years before this, but let me tell you, using graphql/apollo with hooks is such a simple thing, I can't go back to using class components, it's so much simpler like this, loadables are a great concept.
Re:Thinking in React Hooks by duxup on Thursday December 12, 2019 @01:51PM (#21774947)
I love hooks for most things, but what I still struggle with are big higher level components that hosts a bunch of smaller components where I can see componentDidMount, update, etc.... and get a feel for the behavior overall.

With my hooks I've not gotten that visibility but that's probabbly just me getting used to hooks and how to write them better in a way that makes things as clear as the old lifecycle methods.

It doesn't help that I'm bit of a noob as far as web development goes and most examples I look at are pretty straight forward simple apps for teaching the concepts ... but my questions start when things start scaling up.

Re:Thinking in React Hooks by mychael on Thursday December 12, 2019 @01:33PM (#21774730)
Agree 100%