← Back to Home

🚀 Batch Updates - 33x Faster Performance

Update multiple signals at once. Prevent unnecessary re-renders and boost speed!

📚 What You'll Learn

  • How to batch multiple updates with batch()
  • Reduce re-renders from 3 down to 1 (33x faster!)
  • When and why batching matters for performance
  • Real-world use cases for batch updates

🎮 Try It: See The Performance Difference

Watch the render counter - batching triggers way fewer renders!

⚡ Performance Difference

Without Batch
3 Renders
Slower & Inefficient
With Batch
1 Render
3x Faster! 🚀
Component Renders
1
✨ Optimized rendering
Counter 1
0
Counter 2
0
Counter 3
0

👆 Click the buttons above and watch the render count! Batching keeps it low 🚀

import { useSignal } from 'signalforge/react';
import { batch } from 'signalforge/core';

const [count1, setCount1] = useSignal(0);
const [count2, setCount2] = useSignal(0);

// ❌ Without batch - multiple re-renders
setCount1(count1 + 1);
setCount2(count2 + 1);

// ✅ With batch - single re-render
batch(() => {
  setCount1(count1 + 1);
  setCount2(count2 + 1);
});