<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Boika Candy</title>
    <description>The latest articles on Forem by Boika Candy (@boika_boy).</description>
    <link>https://forem.com/boika_boy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3592165%2F35d6ef11-6839-4e51-947e-13291dc5dc0b.png</url>
      <title>Forem: Boika Candy</title>
      <link>https://forem.com/boika_boy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/boika_boy"/>
    <language>en</language>
    <item>
      <title>6 New React 19 Features Everyone Must Use</title>
      <dc:creator>Boika Candy</dc:creator>
      <pubDate>Sun, 02 Nov 2025 10:13:04 +0000</pubDate>
      <link>https://forem.com/boika_boy/6-new-react-19-features-everyone-must-use-42fn</link>
      <guid>https://forem.com/boika_boy/6-new-react-19-features-everyone-must-use-42fn</guid>
      <description>&lt;p&gt;If you're already comfortable with React and looking to level up, React 19 brings some really smart new features and improvements. In this post we’ll cover six of the most useful ones — each with a “before” (React 18 or earlier) and an “after” (React 19) snippet so you can see how things have changed.&lt;/p&gt;

&lt;h2&gt;
  
  
  1) Pass ref as a Prop (No More forwardRef)
&lt;/h2&gt;

&lt;p&gt;Previously, forwarding refs in functional components required React.forwardRef and a little boilerplate. React 19 lets you pass ref directly as a normal prop in many cases.&lt;/p&gt;

&lt;p&gt;Before (&lt;strong&gt;React 18&lt;/strong&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { forwardRef } from 'react';

const MyInput = forwardRef((props, ref) =&amp;gt; {
  return &amp;lt;input {...props} ref={ref} /&amp;gt;;
});

export default function Parent() {
  const inputRef = React.useRef();
  return &amp;lt;MyInput ref={inputRef} placeholder="Type here…" /&amp;gt;;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After (&lt;strong&gt;React 19&lt;/strong&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function MyInput({ placeholder, ref }) {
  return &amp;lt;input placeholder={placeholder} ref={ref} /&amp;gt;;
}

export default function Parent() {
  const inputRef = React.useRef();
  return &amp;lt;MyInput ref={inputRef} placeholder="Type here…" /&amp;gt;;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. New use() API for Resources/Promises
&lt;/h2&gt;

&lt;p&gt;Why it matters: The new use() hook lets you synchronously “read” a promise or resource inside a render. It works nicely with Suspense and server-rendering.&lt;/p&gt;

&lt;p&gt;Before (&lt;strong&gt;React 18&lt;/strong&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Comments({ promise }) {
  const [comments, setComments] = React.useState(null);

  React.useEffect(() =&amp;gt; {
    promise.then(data =&amp;gt; setComments(data));
  }, [promise]);

  if (comments === null) {
    return &amp;lt;div&amp;gt;Loading…&amp;lt;/div&amp;gt;;
  }

  return comments.map(c =&amp;gt; &amp;lt;p key={c.id}&amp;gt;{c.text}&amp;lt;/p&amp;gt;);
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After (&lt;strong&gt;React 19&lt;/strong&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { use } from 'react';

function Comments({ commentsPromise }) {
  const comments = use(commentsPromise);
  return comments.map(c =&amp;gt; &amp;lt;p key={c.id}&amp;gt;{c.text}&amp;lt;/p&amp;gt;);
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Built-in Form Actions + Hooks (useActionState, useFormStatus, useOptimistic)
&lt;/h2&gt;

&lt;p&gt;React 19 introduces better support for form submissions and optimistic UI updates via Actions and hooks that track pending state.&lt;/p&gt;

&lt;p&gt;Before (&lt;strong&gt;React 18&lt;/strong&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function TodoList() {
  const [items, setItems] = React.useState([]);
  const [loading, setLoading] = React.useState(false);

  const handleSubmit = async event =&amp;gt; {
    event.preventDefault();
    setLoading(true);
    const form = new FormData(event.target);
    const res = await fetch('/api/add', { method: 'POST', body: form });
    const newItem = await res.json();
    setItems([...items, newItem]);
    setLoading(false);
  };

  return (
    &amp;lt;form onSubmit={handleSubmit}&amp;gt;
      &amp;lt;input name="item" placeholder="Add todo…" /&amp;gt;
      &amp;lt;button type="submit" disabled={loading}&amp;gt;{loading ? "Saving…" : "Add"}&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After (&lt;strong&gt;React 19&lt;/strong&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"use client";

import { useActionState } from 'react';

async function create(data) {
  // server-side logic
  return await fetch('/api/add', { method: 'POST', body: data }).then(r =&amp;gt; r.json());
}

export default function TodoList() {
  const [error, submit, isPending] = useActionState(create);

  return (
    &amp;lt;form action={submit}&amp;gt;
      &amp;lt;input name="item" placeholder="Add todo…" /&amp;gt;
      &amp;lt;button type="submit" disabled={isPending}&amp;gt;
        {isPending ? "Saving…" : "Add"}
      &amp;lt;/button&amp;gt;
      {error &amp;amp;&amp;amp; &amp;lt;p&amp;gt;{error}&amp;lt;/p&amp;gt;}
    &amp;lt;/form&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Native Metadata, Stylesheets &amp;amp; Script Support in Components
&lt;/h2&gt;

&lt;p&gt;React 19 allows you to declare metadata stylesheet dependencies and async scripts inside components more declaratively.&lt;/p&gt;

&lt;p&gt;Before (&lt;strong&gt;react 18&lt;/strong&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import { Helmet } from 'react-helmet';

function Page() {
  return (
    &amp;lt;&amp;gt;
      &amp;lt;Helmet&amp;gt;
        &amp;lt;title&amp;gt;My Page&amp;lt;/title&amp;gt;
        &amp;lt;meta name="description" content="Hello world"/&amp;gt;
        &amp;lt;link rel="stylesheet" href="/styles.css"/&amp;gt;
      &amp;lt;/Helmet&amp;gt;
      &amp;lt;div&amp;gt;Content&amp;lt;/div&amp;gt;
    &amp;lt;/&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After (&lt;strong&gt;React 19&lt;/strong&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Page() {
  return (
    &amp;lt;&amp;gt;
      &amp;lt;title&amp;gt;My Page&amp;lt;/title&amp;gt;
      &amp;lt;meta name="description" content="Hello world" /&amp;gt;
      &amp;lt;link rel="stylesheet" href="/styles.css" /&amp;gt;
      &amp;lt;div&amp;gt;Content&amp;lt;/div&amp;gt;
    &amp;lt;/&amp;gt;
  );
}




&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Improved Custom Element / Web Component Support
&lt;/h2&gt;

&lt;p&gt;Now you can integrate Web Components more smoothly: props turn into properties (not just attributes) and SSR + client behave more consistently.&lt;/p&gt;

&lt;p&gt;Before (&lt;strong&gt;React 18&lt;/strong&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Using a Web Component inside React – might need workarounds
&amp;lt;MyWebComponent some-prop="value" /&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After (&lt;strong&gt;React 19&lt;/strong&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;MyWebComponent someProp={value} /&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Drop a comment below I'd love to hear your thoughts!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Myths and Facts about Thread Pool in Node.js</title>
      <dc:creator>Boika Candy</dc:creator>
      <pubDate>Sat, 01 Nov 2025 16:50:39 +0000</pubDate>
      <link>https://forem.com/boika_boy/myths-and-facts-about-thread-pool-in-nodejs-3dl5</link>
      <guid>https://forem.com/boika_boy/myths-and-facts-about-thread-pool-in-nodejs-3dl5</guid>
      <description>&lt;p&gt;Node.js is renowned for its non-blocking, event-driven architecture, often touted as "single-threaded" to emphasize its efficiency with I/O-bound tasks. However, this simplicity hides a crucial component: the libuv thread pool, a set of background worker threads that handle blocking operations without stalling the main event loop. In this post, we'll debunk common myths and lay out key facts to help you leverage the thread pool effectively in your Node.js applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  - Myth #1: Node.js is Truly Single-Threaded
&lt;/h2&gt;

&lt;p&gt;A persistent belief in the Node.js community is that the runtime operates on a single thread, making multi-threading impossible or unnecessary. This stems from JavaScript's execution model on the V8 engine, where the event loop processes tasks sequentially.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Fact:&lt;/strong&gt; Node.js isn't entirely single-threaded. While the main JavaScript thread handles the event loop, libuv (Node's C++ backend for async I/O) maintains a default pool of 4 worker threads for offloading CPU-intensive or blocking tasks. This "hidden" multi-threading allows Node.js to perform operations like file reads or cryptographic hashing in parallel without blocking the primary thread. In essence, it's more like a 5-thread model: one for the event loop and four for the pool. Ignoring this can lead to performance bottlenecks in I/O-heavy apps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Myth #2: The Thread Pool Handles All Async Operations
&lt;/h2&gt;

&lt;p&gt;Many developers assume that every asynchronous API in Node.js (like fs.readFile or crypto.randomBytes) magically runs non-blockingly on the event loop without any overhead.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Fact:&lt;/strong&gt; The thread pool is selective—it's only used for operations lacking native non-blocking OS support, such as certain file system I/O, DNS lookups, compression (zlib), and cryptography tasks. Network I/O, for instance, uses OS-level mechanisms like epoll (Linux) directly on the event loop, bypassing the pool entirely. Overloading the pool with mismatched tasks can cause queuing delays, as workers process one task at a time from a shared queue.&lt;/p&gt;

&lt;h2&gt;
  
  
  Myth #3: Thread Pool Size Doesn't Matter—Just Set It and Forget It
&lt;/h2&gt;

&lt;p&gt;It's a common misconception that the default configuration is "good enough" for all workloads, especially since Node.js scales via clustering or worker threads for true parallelism.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Fact:&lt;/strong&gt; The default pool size is 4 threads, tunable via the UV_THREADPOOL_SIZE environment variable (up to 1024, but practically limited by CPU cores). For CPU-bound tasks (e.g., heavy hashing), bumping it to match your logical cores can boost throughput. However, in a cluster setup (using the cluster module), each worker process gets its own pool, so tune per process to avoid resource contention. Mismatches here can turn your app into a bottleneck, especially under high load.&lt;/p&gt;

&lt;h2&gt;
  
  
  Myth #4: Worker Threads Are the Same as the Libuv Thread Pool
&lt;/h2&gt;

&lt;p&gt;With the introduction of the worker_threads module, some conflate it with the libuv pool, thinking they're interchangeable for parallelism.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Fact:&lt;/strong&gt; They're distinct: libuv's pool is a low-level C++ mechanism in Node's async I/O library, offloading blocking native ops (e.g., file I/O like fs.readFileSync or crypto like crypto.pbkdf2) to 4 default worker threads without enabling parallel JS execution. Worker threads, however, spawn explicit JS threads with their own V8 instances for true parallel JS, suiting CPU-bound tasks like data processing—but with serialization overhead for inter-thread communication.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Drop a comment below I'd love to hear your thread pool war stories!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>node</category>
    </item>
  </channel>
</rss>
