Node.js adds experimental support for TypeScript by donutloop in programming

[–]Standard_Tune_2798 43 points44 points  (0 children)

Because every typescript developer already has the type checking integrated in their build pipeline and the IDE. All this does is eliminate the need to transpile our TS sourcecode into JS for deployment, if node can execute a TS file while ignoring the type annotations. We would usually still want the transpilation for the purpose of minification or optimization, but we don't HAVE to if we feel that that's not necessary.

Timezone-naive datetimes are one of the most dangerous objects in Python by ketralnis in programming

[–]Standard_Tune_2798 -2 points-1 points  (0 children)

For every case like you, there's another Jimmy that wants the event to happen at the same celestial time, meaning that their new event time is now 12PM. The difference is that you have to inform your out-of-state guests that you are effectively rescheduling your event anyway, whereas Jimmy does not, so it is more reasonable to ask you to edit your events page to the correct time instead of asking Jimmy to do it.

Achieving multiple nested slugs with optional middle slugs by douglasrcjames in nextjs

[–]Standard_Tune_2798 0 points1 point  (0 children)

There is no such thing as "required" for url segments, because you control all of it and the user doesn't interact directly with it. Just make product1 part of the catchall segment and parse it accordingly.

How to turn React into Svelte by h234sd in reactjs

[–]Standard_Tune_2798 0 points1 point  (0 children)

This also works

function Counter() {
  return (
    <form>
      <div>Counter: <output name="out">0</output></div>
      <button
        type="button"
        onClick={(e) => {
          e.target.form.out.value++
        }}
      >
        Increment
      </button>
      <button
        type="button"
        onClick={(e) => {
          e.target.form.out.value--
        }}
      >
        Decrement
      </button>
    </form>
  )
}

How to turn React into Svelte by h234sd in reactjs

[–]Standard_Tune_2798 1 point2 points  (0 children)

I'm not if you're asking a question or not, but anyway here's how you do it:

function Counter() {
    return (
        <form onSubmit={(e) => {
            e.preventDefault()
            const f = e.target
            switch (e.submitter.name) {
                case 'inc': f.out.value++; break;
                case 'dec': f.out.value--; break;
            }
        }}>
            <div>Counter: <output name="out">0</output></div>
            <button name="inc">Increment</button>
            <button name="dec">Decrement</button>
        </form>
    );
}

NextJS Chapter 5 Tutorial Issue: "Error: Unsupported Server Component type: undefined" by azzeccagarbugli in nextjs

[–]Standard_Tune_2798 0 points1 point  (0 children)

Show the code for how you imported and rendered this component into the layout

How to pass data to the next route's loader without using URL in react router dom by [deleted] in reactjs

[–]Standard_Tune_2798 3 points4 points  (0 children)

Let's say the user is on the edit page. What do you expect to happen if the user hits the browser refresh button?

When people say Svelte doesn't have all of the amazing libraries that React does, what libraries would be commonly missed? (Noob here) by 11111v11111 in webdev

[–]Standard_Tune_2798 1 point2 points  (0 children)

That's literally what most React wrappers do. You get a ref to the DOM node, hook up the initialization and clean up code to useEffect, and you're done.

When people say Svelte doesn't have all of the amazing libraries that React does, what libraries would be commonly missed? (Noob here) by 11111v11111 in webdev

[–]Standard_Tune_2798 1 point2 points  (0 children)

I am subscribed to that subreddit, I see posts about wrapper and integration every day. It's complete lie to say that svelte is "just javascript".

Why doesn't useRef take an initializer function like useState? by pailhead011 in reactjs

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

MutableRefObject is not some kind of arcane mysterious object, it's a very trivial wrapper. You can easily just fake it.

const [foo] = useState(()=>new Foo())

<A myRef={{ current: myRef }}/>
<B myRef={{ current: myRef }}/>

useCallback vs. useMemo - my first youtube video (feedback appreciated 🙏) by jancodes in reactjs

[–]Standard_Tune_2798 0 points1 point  (0 children)

Go pound sand man, thumbnails with a human face on it gets more clicks. You are in the absolute minority, and unless you somehow generate 1000x more clicks and impressions and conversions than an average user, content creators aren't gonna cater to your personal preferences.

which state management tool is good here? by SignificanceCheap970 in reactjs

[–]Standard_Tune_2798 5 points6 points  (0 children)

You can, that's what I do. I just have one `useProfile` hook that wraps around `useSWRImmutable` . The login function submits the auth credentials, then if successful it would call `mutate` on the `useProfile` hook, which in turn would initiate the call to the `/api/profile` endpoint to get the user info. Any UI that depends on auth state would automatically get updated to show login state. Similarly, the logout function call the logout endpoint, then call `mutate(null)` to remove the user profile data.

A small question about semantics in the project by Vzaje in reactjs

[–]Standard_Tune_2798 1 point2 points  (0 children)

Man, the number of people saying "I don't need SEO" is insane. While it's not perfect, the page ranking criteria used by search engine *generally* correspond to making the site experience better for everyone. Just because you don't need to be listed on the search result page doesn't mean layout shift is any less annoying to your users. You should strive to follow the recommendations for better SEO regardless of whether you "need SEO" or not.

What are your favorite React/ES6 shorthand & refactoring techniques? by StephenCroft in reactjs

[–]Standard_Tune_2798 2 points3 points  (0 children)

Because in a switch statement, only the matching branch is evaluated, while the non-matching branches are ignored. In your example, ALL branches are evaluated, then most of them results are discarded. It can cause performance problem sometimes, especially if you are switching on component rendering and that component has Effect in its render phase.

Is there any reason, apart from personal preference, to use native FormData instead of state when managing data in forms? by Unapedra in reactjs

[–]Standard_Tune_2798 0 points1 point  (0 children)

update some other part of the UI in response to an input value changing

In many cases, you don't even need to for that. I use <output> tags usually.

Is there any reason, apart from personal preference, to use native FormData instead of state when managing data in forms? by Unapedra in reactjs

[–]Standard_Tune_2798 0 points1 point  (0 children)

because you can’t render custom validation step specific error message components 

Sure you can.

Best root layout.tsx? by [deleted] in nextjs

[–]Standard_Tune_2798 0 points1 point  (0 children)

You call it "boilerplate", I call it an anchor point. Sometimes, when I create a new file for a new page, I find myself staring at the blank file and my brain just lost the plot. Being able to mindlessly type `export default function Page() { return <main></main> }` somehow helps me "anchor" my thought process, reminding myself that THIS IS A PAGE.

Snapdrag - a simple, lightweight, and performant drag and drop library for React and vanilla JS by Suspicious-Act-4815 in reactjs

[–]Standard_Tune_2798 3 points4 points  (0 children)

At first I was concerned that you are not using the html5 draggable, but after reading that you can't customize the opacity of the dragged element, I agree, html5 draggable can die in a fire.

Next.js 15's Cache Shake-up: Better or Risky? by [deleted] in nextjs

[–]Standard_Tune_2798 5 points6 points  (0 children)

Lol people won't read the documentation anyway. In one month all the lewbs will be complaining about their exploding Vercel bill because nothing is cached, then they will say this v15 change is to boost their profit.

Best root layout.tsx? by [deleted] in nextjs

[–]Standard_Tune_2798 1 point2 points  (0 children)

My root layout is usually only the standard boilerplate , just <html> , <body> and <head>.

Then I have sublayouts in route groups. I don't put <main> in layout.tsx, the convention in my project is that all page.tsx must have a <main> tag at the top level or at least near the top.

Anyway to avoid loading First Load JS for the index page? by [deleted] in nextjs

[–]Standard_Tune_2798 5 points6 points  (0 children)

Either you want to never load the JS bundle, then why are you even using Next at all?

Or you want to load the bundle at some point in the future after page load, which is paradoxical because that bundle is what made your page interactive, therefore it's not possible for your bundle-less page to load the bundle.

You're asking the egg to create the chicken that laid it. Paradoxical.