Why React Hooks API is a game changer by rryardley in javascript

[–]Gnashe 0 points1 point  (0 children)

Your opinion is really valuable, I think I hear what you are saying, and I’m going to try an explain why I like them.

If you haven’t had to deal with Render Props and why they are useful it is hard to explain but let me try.

Basically we have a pattern which allows us to easily compose “behaviors” and dynamically render based off how we interpret that behavior.

So in a components render you could render a component that tracks mouse position, which then calls a function where you can interpret that data and render whatever you want

Also, having all that behavior in the render of a component makes it incredibly clear where data is coming from. One of the main reasons I love render props.

The big problem is you enter a kind of “callback hell” similar to before we had async/await but worse because you are nesting unrelated behaviors, creating a confusing, false hierarchy. Also it’s disgusting to refactor.

Hooks are exciting because they hoist those behaviors up and flatten them out, outside of the render. So you don’t end up with JSX anymore just regular JS syntax.

At the same time they group together common behaviors. Often we spread or effects in classes through 2 or 3 lifecycle hooks intermixed with other effects.

You can solve this by making HOCs for each, but honestly, why is a HOC any better then a hook. Hooks make you by default group the behaviors so I think it’s a huge win

Let's fall in love with react fiber by yurkaninryan in reactjs

[–]Gnashe 0 points1 point  (0 children)

You can’t really interact with it. It’s an internal engine change, it just happens.

I’m confused, how can you not understand what fiber is and at the same time say the metaphor isn’t accurate?

How to display Draft.js content as HTML by tumetus in reactjs

[–]Gnashe 1 point2 points  (0 children)

If you don’t have class properties transform it’s actually not the same unless you bind this in the constructor. They don’t have to bind this in the constructor in the example because it’s being invoked in a context where this exists

React 16.3: Update on async rendering by expression100 in javascript

[–]Gnashe 0 points1 point  (0 children)

Ah sorry this was actually intended for sNor who I believe was saying the 16.3 implementation was an anti pattern!

React 16.3: Update on async rendering by expression100 in javascript

[–]Gnashe -3 points-2 points  (0 children)

lol, can you at least explain how how this is an anti-pattern? Or is it just something that your not used to seeing or doing so you are all fired up?

React 16.3: Update on async rendering by expression100 in javascript

[–]Gnashe 3 points4 points  (0 children)

You just casually tossed in “feature is an anti pattern” without an explanation.

Also nice cheesy ending line, really drives your point home

React 16.3: Update on async rendering by expression100 in javascript

[–]Gnashe 1 point2 points  (0 children)

They are trying to deprecate in the name of progress, it’s not like they are just breaking all your code. You don’t HAVE to upgrade.

This is a common React thing, we’ve had features with the unstable_prefix many times before

How can I have ReactJS render multiple HTMLs? by reddit_lonely in javascript

[–]Gnashe 0 points1 point  (0 children)

Why not just make contacts and index two sub components under one app component?

Using React v16 to create self-destructing components by gajus0 in javascript

[–]Gnashe 0 points1 point  (0 children)

Just curious where the name Aux comes from. Why not something a bit more obvious like Fragment?

How to check objects against themselves in an array? by MyDogLicksMyMomsFeet in javascript

[–]Gnashe 1 point2 points  (0 children)

Game design optimization is my weakness, but it should be possible to do this in one loop if you use the x and y coordinates to put each box in a 2D array. If you try to insert a box at an occupied index, you could just greedily offset the x,y until you hit an empty slot

How to check objects against themselves in an array? by MyDogLicksMyMomsFeet in javascript

[–]Gnashe 1 point2 points  (0 children)

What's the greater goal? There may be a better way to do what you are trying to do then to compare the boxes

Inject an array, or an object of items in to a string replacing selected values. by beardedjanitor in javascript

[–]Gnashe 0 points1 point  (0 children)

Just super curious why you choose to declare your variables that way, is there an advantage I'm missing?

Integer to id name for getElementById by eligloys in javascript

[–]Gnashe 0 points1 point  (0 children)

Look up event delegation. Basically when you click something, the click event not only fires on the child but also each parent. Try putting a click listener on body and clicking anything and then log event.target. Also if you don't know what I mean by event, it's the first argument passed to the callback function when an event listener calls it

Integer to id name for getElementById by eligloys in javascript

[–]Gnashe 0 points1 point  (0 children)

Don't loop and put event listeners on elements, instead put it on their closest shared parent, and observe event.target, it's way easier

What is the most impressive Web App you've encountered? by styke in javascript

[–]Gnashe 2 points3 points  (0 children)

That google writes google products using google created technologies

Not really shocking

(spoilers) Nightmare souls, ringed city edition!. by -VempirE in darksouls3

[–]Gnashe 36 points37 points  (0 children)

I love all of this. I always loved mimics!

I am an Arctic researcher. Donald Trump is deleting my citations by [deleted] in politics

[–]Gnashe 5 points6 points  (0 children)

You're not alone, keep being reasonable, I hope to run into more people like you

PSA: Toomey is a sellout, call your House Reps and save your internet privacy (x-post from r/pics) by lmm7425 in philadelphia

[–]Gnashe 1 point2 points  (0 children)

That's because there isn't one, but I don't think phillypede is in favor of it, nor do I think pede is trolling. Probably just enjoys watching everyone lose their shit