Navigate Select ESC Close

React's New Controversial Override

2024-05-08 Science & Technology
52.7k
1.4k
241
Theo - t3․gg
Theo - t3․gg
539.0k subscribers

Unlock all features

FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.

Description

Oh boy. This again. React is patching another global, this time it's `Date` SOURCE https://twitter.com/acdlite/status/1785691330988986587 Edited by Ph4se0n3

Top Comments (10)

@StiekemeHenk 2024-05-08

They should instead add their own date that explicitly specifies server or client date and warn devs in the console if the regular date is used.

284 8 replies
@SourceOfViews 2024-05-08

Still just a library btw.

232 3 replies
@Scereye 2024-05-08

Why does "it suck" that the serverside Date() spits out it's current date and the clientside Date() (if "use client" is stated) spits ITS current date out? To me this is expected... No? Like, I get that it's unfortunate and that red equals bad, but... that's just SSR things for you, no...? I feel like every potential change to "fix" this just introduces more harm than good. But oh well, we will see...

111 14 replies
@ReasonX3 2024-05-08

Polyfills usually have checks that will apply them only if the target functionality is absent. In other words their initialization looks something like this: *window.something = checkForSomethingFunctionalitySomehow() ? window.something : somethingPolyfill;* At least its definetly how Array and Object static and prototype methods are applied, which makes sense, especially from the point of performance. Wouldn't it make more sense to create a separate *React.Date* object that would work the same way as original Date plus hydration fix? Adding *import { Date } from "react"* should be a pretty easy fix and most importantly its very obvious for everyone. I remember when I worked with Angular 1, provided its own function, like setTimeout, that could be injected into components and services via dependency injection.

52
@StephanHoyer 2024-05-08

Hurray, new footguns to stick in the holes in the old ones shot 🙄

46
@vikingthedude 2024-05-08

Next up: We’re patching Math.random()

43
@JoeyClover 2024-05-08

It's stupid. It solves one of many issues, because you're hydrating with non-idempotent logic. What's next? Are they just going to patch anything that isn't idempotent lmao. SOLVE THE FUNDAMENTAL ISSUE.

41
@swiclabc 2024-05-08

Nice, so they are going to break formatting by locale in the browser and timezones...

30 1 replies
@echobucket 2024-05-08

They should just add a `useDate` hook that you can use that just gives you a date object with the date that was created on the server.

27 1 replies
@adaliszk 2024-05-08

Aren't polyfill by nature only patches when the feature does not exist? While technically does the same patching, it feels different as by design its meant to be not used when possible.

13

Unlock the Data Inside
Turn Videos into Knowledge

  • Get FREE 10/day: transcripts, summaries, chats
  • Chat with videos, export text & PDF
  • $1 free API credit for RAG, chatbots & research

Free forever plan • All features unlocked

App screenshot