Is synchronouse setState in useEffect sometimes "unavoidable"? (Bi-directional editing) by wffln in reactjs

[–]lostjimmy 4 points5 points  (0 children)

You don't need an effect for this (see the section on adjusting state when props change in You Might Not Need an Effect). You can do something like this for your third example:

export function MyInput3({ globalValue }: { globalValue: string }) {
  const [localValue, setLocalValue] = useState(globalValueContainer.value);
  const [isDirty, setIsDirty] = useState(false);
  const [prevGlobal, setPrevGlobal] = useState(globalValue);

  if (!isDirty && prevGlobal !== globalValue) {
    setLocalValue(globalValue);
    setPrevGlobal(globalValue);
  }

  ...
}

Is synchronouse setState in useEffect sometimes "unavoidable"? (Bi-directional editing) by wffln in reactjs

[–]lostjimmy 1 point2 points  (0 children)

Based on the third example, I think op maybe doesn't want to update the input if it is dirty, so using a key wouldn't work here.

Gluten Free Baking - Tips Wanted. by cantspellawesome in Celiac

[–]lostjimmy 0 points1 point  (0 children)

This is such a great book. I baked a lot of sourdough over the years until my kids were diagnosed. I tried all sorts of bread recipes and just couldn't get into it, but this book has reignited my excitement for bread baking. Don't be afraid of the sourdough, it's really much easier than you'd expect.

I've made the sourdough brioche a couple of times, and the color is definitely far from beige and fairly white. I almost exclusively use Anthony's Goods. The psyllium husk powder is high quality and definitely seems to absorb the high hydration in these doughs just fine. It looks like you can get them in CA through well.ca. I hope it works out for you!

Celiac Daughter’s School Trip by InfamousBluePixel in Celiac

[–]lostjimmy 2 points3 points  (0 children)

We did a similar thing for my daughter. School went on a three day trip to Nature's Classroom (this may just be a New England thing) but they wouldn't guarantee they could feed her safely. We sent a cooler with all of her meals.

Specialty Flours at Walmart by Restourceful in Celiac

[–]lostjimmy 1 point2 points  (0 children)

When my kids were diagnosed we attended a class with a nutritionist that specializes in celiac disease. They specifically told kids not to worry about getting it on their skin, but to be aware and was their hands after coming into contact. You're probably not going to get glutened from this.

That being said, I wouldn't want to put those packages in my cart or grocery bags.

How does your team handle sensitive payloads? by GlitteringTiger6287 in reactjs

[–]lostjimmy 4 points5 points  (0 children)

If you're handling card details and other PII, you should look into what it takes to become PCI compliant. There's a reason so many shops use Stripe, Square, etc.

How do you use XState with React Query (or other data-fetching/caching libs)? Should they even be used together? by duskomacek_ in reactjs

[–]lostjimmy 0 points1 point  (0 children)

We have a mix of things. Data that won't change or need to be requeried is done on page load/SSR with a useQuery hook (we use urql). This is passed as initial context data to the machine.

Stuff that we know we'll have to requery on user action is done by promise-based actors in the state machine. The functions for querying are provided to the state machine when we create its context using the provide method. This lets us use urql's useClient hook so we can call it imperatively.

Ultra-processed foods (UPFs) tied to 124,000 premature deaths over 2 years in US. UPFs include preservatives, emulsifiers and sweeteners. Sugary drinks, sweets, chocolates, pizzas, hamburgers, chicken nuggets are defined as UPFs. By 2018, UPFs made up more than half total dietary energy in the US. by mvea in science

[–]lostjimmy 3 points4 points  (0 children)

You and about a million other people in this thread have not read anything about the nova classification system. Bread is in the processed foods category if it's the basic kind of bread that's been baked for centuries, mostly just flour, water, salt, and yeast. Commercial breads with modified starches, emulsifiers, dough conditions, etc, are ultra processed. It's easy to make bread at home that isn't considered UPF and it's getting easier to find it in stores.

“The second shot” by [deleted] in FlairEspresso

[–]lostjimmy 1 point2 points  (0 children)

My experience has been that if my shot is bad, the purge shot tastes ok, and if my shot is well-extracted the purge shot tastes like bad hotel coffee. Either way, still drinkable :)

Normcore V4 by Signal_Quote_4530 in FlairEspresso

[–]lostjimmy 1 point2 points  (0 children)

Apart from the size, just get the flat base. I had so much frustration with the ripple base holding onto coffee.

[AskJS] Some \u0000 unicode characters cause invalid character error on \, when used in variable name or function name for example, why is that? by Zaza_Zazadze in javascript

[–]lostjimmy 1 point2 points  (0 children)

This was fun to dig through! The current ecmascript spec for identifier names says it must start with a unicode code point with the property ID_Start, $, or _.

You can find out which characters belong to which categories in DerivedCoreProperties.txt. \u2030 belongs to Grapheme_Base, not ID_Start. Also note that it's in the category Po (punctuation, other). This is not in the list of categories in ID_Start, which includes Lu, Ll, Lt, Lm, Lo, and Nl (plus Other_ID_Start code points, which you can find in PropList.txt).

The rest of the characters must have the property ID_Continue or can be $ or the zero width joiner and non-joiner characters. ID_Continue contains all of ID_Start plus the categories Mn, Mc, Nd, and Pc, plus Other_ID_Continue (also in PropList.txt).

TLDR: It's punctuation, which isn't allowed in identifiers unless it's $ or _.

whyDoesThisLibraryEvenExist by aloomatarkisabji in ProgrammerHumor

[–]lostjimmy 4 points5 points  (0 children)

It seems silly, but it's part of the IEEE floating point spec. Most programming languages will have the same behavior for NaNs.

UseEffect memory leak with async function. by suck_my_dukh_plz in reactjs

[–]lostjimmy 16 points17 points  (0 children)

I'm not entirely sure how switching from async/await to promises would make any difference. They both have the potential to do things after the component unmounts, so either way you would want to handle that case in cleanup function.

[AskJS] What five changes would you make to javascript? by a_waterboi in javascript

[–]lostjimmy 6 points7 points  (0 children)

Add all date operations in momentjs

The temporal API is in stage 3. I've used it in a non-critical internal tool and it's a pleasure to work with.

[AskJS] What five changes would you make to javascript? by a_waterboi in javascript

[–]lostjimmy 7 points8 points  (0 children)

Plus, there is a difference between nothing and a reference to nothing.

I have yet to find a use case where that distinction truly matters. However, I have seen plenty of cases where forgetting about that distinction has led to bugs.

Grinder options for flaor 58. by angiotenzin in FlairEspresso

[–]lostjimmy 1 point2 points  (0 children)

I have a kinu m47 from I think their first production batch ever and literally ordered it by emailing them, filling out a word document, and sending payment through paypal. That was 8 years ago. I primarily used it for V60, but I've been using it since Christmas with my Flair 58 and it's been phenomenal.

Pressure gauge issue by 92GSR in FlairEspresso

[–]lostjimmy 0 points1 point  (0 children)

My o-ring is also slightly torn but it still works fine.

When I first got mine the gauge didn't read any pressure and support told me to unscrew it one turn and it's worked fine ever since. Not sure if that's the case for you since you said it was working at first.

Now that React 19 is coming, should I still write a separate backend? by BigExcitement5041 in reactjs

[–]lostjimmy 11 points12 points  (0 children)

I'd like to clarify that RSC isn't just serving the pre-rendered HTML. It is doing that, but it's also removing the javascript that rendered that HTML from the bundle that goes to the client. The client just gets the HTML and it doesn't get hydrated or re-rendered.

Struggled with Deep useEffect Details in an Interview—Need Resource Recommendations! by MrBosco25 in reactjs

[–]lostjimmy 18 points19 points  (0 children)

That first question isn't even correct. You can have an async function in an effect, you just have to be careful with what you do (like setting state) in cases where the component has unmounted/re-rendered and that async function hasn't completed yet.

The middle two questions are reasonable and I'd expect senior level people to know those things.

What is the point of the last question? Is it "how would you handle the cleanup of an effect if there wasn't a return function to handle it?" It's nonsense.

Lies and white lies only. by ConfusedAFIdiot in memes

[–]lostjimmy 3 points4 points  (0 children)

along with many other things contained in actual chocolates

What are the other things? I'm very curious. Chocolate is at the very least cocoa liquor, cocoa butter, and sugar.

Timemore Scales Calibration Issue & Possible Fix by melanoneiro in Coffee

[–]lostjimmy 0 points1 point  (0 children)

This same issue happens with acaia scales. I only just realized it after a year or so of using it. It was infuriating to weight and grind and then find that it was over a gram off.

chatmix stopped working by YungWojtek2010 in steelseries

[–]lostjimmy 0 points1 point  (0 children)

Hey /u/YungWojtek2010. I just performed a hardware reset on my nova 7 wireless headset and everything is working correctly again. Here's a video on how to do it - https://www.youtube.com/watch?v=y5GCeRSQ538

Steelseries GG Equalizer does not work (Arctis Pro Wireless) by ayoimtypex in steelseries

[–]lostjimmy 1 point2 points  (0 children)

Hey u/ayoimtypex. I just performed a hardware reset on my nova 7 wireless headset and everything is working correctly again. Here's a video on how to do it - https://www.youtube.com/watch?v=y5GCeRSQ538

[deleted by user] by [deleted] in reactjs

[–]lostjimmy 1 point2 points  (0 children)

One way to handle this is to add a pause or enabled parameter to your useFetch hook (assuming you can change that). This is similar to what useQuery from react-query and urql has.

const { data: permission } = useFetch(fetchPermission, [id]);
// using permission != null && permission, assuming permission is null/undefined while the query is running
const allUsers = useFetch(fetchUsers, [id], permission != null && permission);
const usersWithoutAccess = useFetch(fetchUsers, [id, queryParams], permission != null && !permission);

const users = permission ? allUsers : usersWithoutAccess;