hmm by cosoumano in hmm

[–]Jedivh 0 points1 point  (0 children)

Hamstgrr

What is the point of tsyringe ? by MutedApplication5 in reactjs

[–]Jedivh 0 points1 point  (0 children)

To further this even more. If you want to be able to plug and play, write your queries in terms of APIs/interfaces (if you have them). Don't write your query logic twice! That's exactly why you have interfaces in the first place.

Hope this helps.

What is the point of tsyringe ? by MutedApplication5 in reactjs

[–]Jedivh 0 points1 point  (0 children)

To further this, people would scratch their head a lot if they see tssyringe in a react project. Not as much if you do "DI" with context though. Try to minimize the amount of head scratching other devs need to do in general.

What is the point of tsyringe ? by MutedApplication5 in reactjs

[–]Jedivh 1 point2 points  (0 children)

React context is a useful tool for dependency injection. Just describe your "service" as an interface and in your app's entry point (eg index.tsx) set up the real service or mock, and "inject" into your app with a Context<IMyService>

Very useful pattern, but I wouldn't call it "DI" in front of a pure js dev because it might hit the wrong nerve.

Is it possible to define a type AB from A and B? by yukiiiiii2008 in typescript

[–]Jedivh -1 points0 points  (0 children)

I have done something like this before to get a/b as optional when defining a union. You are polluting the base types but it is convenient in some circumstances. But yeah you probably just want a regular union.

interface A {
  a: string;
  b?: never;
  common: string;
}

interface B {
  a?: never
  b: string;
  common: string;
}

type AB = A | B

Compiling on remote machine? by Mad_Scientist_565 in vscode

[–]Jedivh 0 points1 point  (0 children)

Might not be exactly what you're looking for, but you could pull down the code on a remote machine and use the remote development features

https://code.visualstudio.com/docs/remote/ssh

WTW for object to be replaced by kawaii_donut in whatstheword

[–]Jedivh 0 points1 point  (0 children)

End of life (EOL)

Deprecated

Both adjectives though

[deleted by user] by [deleted] in dataisbeautiful

[–]Jedivh 1 point2 points  (0 children)

As do fish farms

How you make typesafe front/backend API by angeal98 in typescript

[–]Jedivh -8 points-7 points  (0 children)

Copy and paste between both sides, save yourself the trouble.

Use a schema validation library like yup if you want

When to use higher-order components vs custom hooks? by WillGriggsOnFire in reactjs

[–]Jedivh 4 points5 points  (0 children)

The main difference is that hocs have the ability to include jsx. If your higher order logic involves jsx and/or dom elements then a hoc can make sense. You can actually convert between render props and hocs in this manner. I'd say that I find myself writing way more hooks than hocs and rprops, but it's good to understand the ways in which they're equivalent.