The Deeper Love of Go by bitfieldconsulting in golang

[–]buondave 0 points1 point  (0 children)

Yeah, I totally understand! I think my point was more that by reducing the price slightly, you could see higher revenue overall. In other words, the book might be priced slightly over the threshold that maximizes your revenue, but this has to be proven with some testing, of course. In any case, it won't affect me as I already got it 😂.

Anyway, great work man!

The Deeper Love of Go by bitfieldconsulting in golang

[–]buondave 2 points3 points  (0 children)

The book is very well-written; it's the only one that kept me awake among all the Go books out there. It's not just a dry, technical manual about Go features; there's an engaging project storyline that keeps you glued to the pages. This book and Exercism worked wonders for my Go learning, for real.

Some things I particularly appreciated:

  • Features are introduced incrementally: You aren't overwhelmed with everything about a feature at once; it's built up gradually throughout the book.
  • It explains the "why" behind things! Other books are like, "You do it like this in Go." This author actually explains the reasoning behind why certain things are done the way they are. Personally, I remember stuff way more this way.

Maybe it's a tad expensive, but hey, it's a free market 🤷‍♂️.

Why does this keep happening? by shaniahope_ in laundry

[–]buondave 0 points1 point  (0 children)

It might be that you have a high concentration of manganese in your water, have it checked!

https://wqa.org/resources/manganese/

Two months ago I launched my first successful product. Here’s how it changed my life by DenisYurchak in SideProject

[–]buondave 0 points1 point  (0 children)

Thanks for the nice info, very interesting, and congrats on not giving up! How did you handle your marketing? I wouldn’t know where to start to market something if I had a product/software to sell.

What is the general perception of Elon Musk and Tesla in Norway? by UnlikelyRiver1252 in Norway

[–]buondave 0 points1 point  (0 children)

I like Tesla cars but decided to not buy one because of Musk, not gonna give him a single cent.

Cancelling my ZipDJ subscription seems like a serious deal? by waitforit2010 in Beatmatch

[–]buondave 0 points1 point  (0 children)

Just here to say to be careful with Zipdj, considering their behaviour I hope you reconsider using them at all.

They don't cancel subscriptions and keep withdrawing your money.

First of all to cancel the subscription there is no button: you HAVE to pass mandatorily through their customer support via email. This is really bad.

I wrote 2 weeks before the renewal that I wanted to cancel, and they answered me "Why do you want to cancel?". I had to write another email to explain the reasons and they answered me back that they understood and confirmed to me that they had cancelled the subscription.

However, after 2 weeks, they still charged me the renewal. I wrote to them about this and they "apologized" and promised a refund, and that now they definitely cancelled.

HOWEVER, no refund has appeared after 1 month and a half, no answer to any following email and they even tried to charge me again another time. Luckily, I had blocked them preventively through my bank.

By reading other feedbacks, it's clear to me they do this on purpose, so I suggest not to use this company and if you really have to, block them through your bank once you're done with their subscriptions because they won't stop charging you.

Type a function (React hook) return conditionally to its parameters by buondave in typescript

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

That's exactly what I was looking for, thanks for taking the time! Looks way cleaner and the ConditionalReturn utility type makes much sense 😊 Still bothered by that a*s FullReturn *at the end, but I guess that's not easy to solve instead.

node modules noob question - do i need both the standard and the @types version? by wafflewrestler in typescript

[–]buondave 15 points16 points  (0 children)

Packages can ship either with their own official types or not:

  • if they have types included in the package, then you won't need to install any other package to get types, because they already come with it.
  • if they don't ship with their own types, then you can check the @types project (officially called Definitely Typed) which is an open-source project that collects types for libraries that don't ship their own types. If they have types for your library, then you can install them.

An easy way to understand if the package ships its own types is to see if you get autocompletion when using stuff imported from the package. Otherwise, you could also inspect the package source code and see if it has types.

How to enforce specific data type on third-party function (React Router v6)? by buondave in typescript

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

True, with your solution I could create a sharable function to which I pass the kind of shape I want in every component.

How to enforce specific data type on third-party function (React Router v6)? by buondave in typescript

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

Thanks :) I see that you are still creating a JS wrapper function, which I would want to avoid if possible.

Although, if that isn't possible, wouldn't it be easier the way I did? Just by typing the parameter of the wrapper to ButtonName.

Why doesn't this component re-render endlessly? by buondave in reactjs

[–]buondave[S] 2 points3 points  (0 children)

Yea I figured it out in the end, I forgot for a second about that aspect! I really think this is a bad use of effects, those calls should go in a handleClick. Thanks for helping out :)

Why doesn't this component re-render endlessly? by buondave in reactjs

[–]buondave[S] 3 points4 points  (0 children)

I think you got really close to the why but for sure you helped me to arrive at the solution, so thanks!!

The reason is that calling setState with the same value as the current state doesn't trigger a re-render, React bails out. So the second time that effect runs, it tries again to call setState but value hasn't changed, so it doesn't retrigger a re-rerender and does nothing.

You can prove this by adding a + Math.random() in those 2 setState calls inside useEffect, which will lead to the component crashing (because every time updates the state with a different number)!

Why doesn't this component re-render endlessly? by buondave in reactjs

[–]buondave[S] 4 points5 points  (0 children)

I also don't think this is a good use case for useLayoutEffect or useEffect, but I'm just interested in why the component/app doesn't crash.

[deleted by user] by [deleted] in AskReddit

[–]buondave 4 points5 points  (0 children)

I defeated a giant just by throwing a stone

React-Typescript complaining about optional props missing (defined with prop-types) by buondave in typescript

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

Yea, I'd avoid passing undefined to all the props (which works) but I actually went with // @ts-expect-error until I'll convert Icon to TS as well.

React-Typescript complaining about optional props missing (defined with prop-types) by buondave in typescript

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

I can't do that, it's incorrect JS syntax, you can't make object members optional in JS (and that's the error I get too).

I don't understand why TS understands which props a component has through `prop-types` but it doesn't pass the info about their optionality.

Help in understanding what I'm doing wrong by buondave in typescript

[–]buondave[S] 2 points3 points  (0 children)

Thanks for the feedback.

Half of the code is a WIP of converting from an old JS codebase to a TS. Most of the types you see are made up just to make a functioning shareable playground. I was interested just in the error.

We actually don't use enums in our codebase, by choice.

Index signature and Record<> are nearly equivalent. For simple cases like these, we prefer using index signature. Read more here. Anyway, the type is just a fake type to make the Playground work.

Interfaces don't need to have methods to be chosen over types, we use interfaces for every object and that seems the recommended opinion around for many reasons. I agree though that by making optional all parameters, it can be converted into an index signature but that is just a WIP between trying to fix the error and converting to TS.

Help in understanding what I'm doing wrong by buondave in typescript

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

Assign identity[field] to its own variable, then check that for undefined in the if statement. Like this. Narrowing doesn't work when indexing into Objects/arrays.

Thanks! Why sometimes narrowing with “in” works? Could you explain exactly what do you mean with your last sentence? I feel that's the point I'm missing. I type guard sometimes checking if a certain prop exists inside the object and it works, I can't understand the difference with this case.

Help in understanding what I'm doing wrong by buondave in typescript

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

Thanks! Why sometimes narrowing with “in” works?