r/reactjs • • 19h ago

Discussion Hot take: for most small React projects, useState + lifting state up is enough — I only reached for a state library when props got silly

0 Upvotes

Been learning React properly over the last few months while working a full-time marketing job and studying BCA, so most of my projects are small — a portfolio site, a couple of client landing pages. Early on I thought I needed Redux for everything because every tutorial mentioned it. In practice, useState and passing props down got me through all of it. The one time I actually felt the pain was a multi-step form where the same data was needed three components deep and I was passing props through components that didn't care about them. That's when I tried Zustand and it clicked. Curious — what was the moment you knew you actually needed a state library, and which one did you pick? Or do you still avoid them?


r/reactjs • • 22h ago

Resource How I load fonts for a first-screen hero in React 19 without a flash (preconnect + critical/late split)

Thumbnail
motionuikit.io
0 Upvotes

I ran into this while building a hero with a canvas animation. The headline font has to be there on the first paint or the whole screen visibly jumps, but loading every font up front slows the page. What worked for me was splitting fonts into two groups.

  1. Critical fonts: the ones the first screen can’t look right without (headline and UI). I render these as a stylesheet link with a precedence prop, so React treats the stylesheet specially.
  2. Late fonts: decorative ones that only appear after interaction or in small labels. I load these after mount, so they never block the first paint.
import { preconnect } from 'react-dom'
import { LateFonts } from './late-fonts'

const CRITICAL_FONTS =
  'https://fonts.googleapis.com/css2?family=Archivo:wght@800&display=swap'
const LATE_FONTS =
  'https://fonts.googleapis.com/css2?family=Martian+Mono:wght@400&display=swap'

export default function Hero() {
  // React places these hints in <head>, ahead of the stylesheet
  preconnect('https://fonts.googleapis.com')
  preconnect('https://fonts.gstatic.com', { crossOrigin: 'anonymous' })

  return (
    <>
      <link rel="stylesheet" href={CRITICAL_FONTS} precedence="default" />
      <LateFonts href={LATE_FONTS} />
      <main>{/* hero content */}</main>
    </>
  )
}



'use client'
import { useEffect } from 'react'

export function LateFonts({ href }: { href: string }) {
  useEffect(() => {
    const link = document.createElement('link')
    link.rel = 'stylesheet'
    link.href = href
    document.head.appendChild(link)
    return () => link.remove()
  }, [href])
  return null
}

Things to watch:

  • precedence is what makes React handle the stylesheet specially. Without it, you get a plain <link>.
  • A component that renders a stylesheet link with precedence suspends until the stylesheet loads, so decide where your Suspense boundary sits.
  • preconnect only helps if you call it while rendering.
  • I left out the late fonts’ fallback styling. If a late font changes layout, you may still see a small shift.

Curious how others split font loading for first-screen sections, or whether you just self-host everything.


r/reactjs • • 9h ago

Show /r/reactjs I built Lexion, an MIT-licensed headless rich text editor on ProseMirror with adapters for 10 frameworks

Thumbnail
reddit.com
0 Upvotes

r/reactjs • • 1h ago

News One Year After React2Shell Patch, Thousands Of Servers Are Reported To Have Had Keys Stolen

2 Upvotes

CloudSEK has published a report on November 30, detailing a campaign they are calling React2Keys. Tens of thousands of credentials from thousands of hosts, per CloudSEK.

They got the keys, tested them, used them and charged victims for using AI/Cloud under their stolen keys. They also added new SSH keys to the servers without the server owner's permission.

Upgrade to 19.0.1, 19.1.2, 19.2.1+, or patched Next.js version. Take all the secrets that were stored on the server, cycle them through. Revoke the old keys. Check the authorized_keys of your accounts, and toss any SSH key which you can't associate with a person or system. You should look at the November bills for the accounts that you can access with those keys and see if there is any usage you don't recognize.

Also reported this week by SecurityWeek and CSO Online. The fact the flaw exists, the fixes and the CISA KEV listing are all public knowledge. So the "patch & rotate" part is worth doing even just based on that.

https://hol.org/blog/cve-2025-55182-react2shell-react2keys-campaign