React 19 Features Explained
React 19 Features Explained
CODE WITH
REACT-19
ANKIT KUMAR
New use() Hook
Used for data fetching and
consuming async values (like
context or promises).
index.jsx
01
useFormStatus
It detects if a form is submitting
to show loaders or disable
buttons.
index.jsx
return <>
<button type="submit" disabled={pending}>
{pending ? 'Submitting...' : 'Submit'}
</button>
</>
}
02
useActionState
It helps run async functions (like
form submits) and keeps track
of the result or response.
index.jsx
function StatefulForm() {
const [state, formAction] = useActionState(increment, 0);
return <form>
{state}
<button formAction={formAction}>Increment</button>
</form>
}
03
useTransition
useTransition in React performs
non-urgent updates, improving
UI responsiveness.
index.jsx
return <>
<button onClick={increment}>Increment</button>
{isPending ? <p>Loading...</p>: count}
</>
}
04
useOptimistic
Updates the UI instantly with a
predicted result while waiting
for the server
index.jsx
05
createContext
You can use context directly as
the provider eliminating
.Provider suffix.
index.jsx
06
Passing ref Directly
In React 19, forwardRef is
deprecated; pass ref directly.
index.jsx
// ref Example
function MyInput({ ref, ...props }) {
// The 'ref' prop is passed directly to the input element.
// The rest of the props (like 'value', 'onChange', etc.) are
spread onto the input.
return <input ref={ref} {...props} />;
}
07
React Compiler
Now, React automatically optimizes
your components by tracking
dependencies.
No need for useMemo, useCallback, or
memo.
index.jsx
// Before React-19
const memoizedVal = useMemo(() => ExpensiveVal(a,b),[a,b]);
// After React-19
const value = expensiveValue(a,b); // Automatically optimised
08
Server Components
Native integration to server
components providing SEO &
improved performance
index.jsx
09
Thank You!
Thanks for going through this ReactJS update guide.
I’d love to connect and chat more about React or
web development!