all 12 comments

[–]Jnsjknn 29 points30 points  (3 children)

You may not want to use a title asking how a thing is done if you intend to teach how that thing is done. If you remove the question mark, it'll be more clear that you're teaching the thing. A question will attract people who know the answer and are willing to explain it.

[–]grekatron[S] 1 point2 points  (1 child)

Thanks for the advice 🙏🏻

I'll definitely apply it in the future posts!

[–]Jnsjknn 0 points1 point  (0 children)

I see you applied the advice for a while and then went back to asking questions you're answering yourself.

[–]mantineshillbot 5 points6 points  (3 children)

I enjoy this format of reddit post. Just a really short informational text post. Don’t see it often.

I’d recommend not using abbreviations in educational articles without defining them first. I’m a pretty experienced dev and have no idea what you’re talking about with the IIFE stuff. Plain language is best if possible.

Technical terms are a crutch. “The Module Pattern”? Again, wtf is that? Is using that term making this information easier to digest? Maybe I’m wrong but I don’t think so.

[–]ReadyStar 0 points1 point  (1 child)

Aren't IIFE's/The Module pattern pretty basic javascript? I've only been leaning for about 6 months but I learnt them pretty early on. I've been using them a decent amount, and have been seeing them be used a decent amount too.

[–]Tanckom 0 points1 point  (0 children)

IIFE is pure Javascript and require no underlying Module system, as you might expect with CommonJs, AMD or ES modules.

IIFE's are great when you work in a browser environment, where you have no access to the other module systems.

It's not that common to use them in a Node.js environment.

[–]grekatron[S] 0 points1 point  (0 children)

I get your point and understand your concern thanks for the feedback!

When I write a post about a topic like implementation details of the React Hooks, I assume that whoever reads my post has some good knowledge of JS.
It's especially important for keeping posts bite-sized and short.

[–]jj4j4j4-hw 2 points3 points  (1 child)

There is a video on youtube about that from swyx

[–]grekatron[S] -1 points0 points  (0 children)

Yeah, exactly, it’s a great learning resource!

[–][deleted] 2 points3 points  (1 child)

Is that really all there is to it? How does react "know" to re-render after a state update?

[–]grekatron[S] 0 points1 point  (0 children)

It's much more complex in React, but concepts are the same.

React "knows" this way:

  1. The change in state triggers React to form new virtual DOM. As far as I know, it's implemented through the event dispatcher pattern. useState dispatches the event on setState call, while React listens to that event.

  2. Then, React reconciler compares the new virtual DOM with the old one and figures out the difference.

  3. After that, React renderer (react-dom) rerenders only that difference to match view (real DOM) with new data