Skip to content

Release 4.0.0

Latest

Choose a tag to compare

@mCodex mCodex released this 27 Apr 18:57

πŸš€ v4.0.0 β€” Providerless, High-Performance Toasts

A complete rewrite. No provider, no Reanimated, no gesture-handler β€” just a tiny, tree-shakeable, WCAG 2.2 AA toast system built on useSyncExternalStore.


✨ Highlights

  • πŸͺΆ Providerless API β€” Drop a single <Toaster /> anywhere in your tree. The <ToastProvider> wrapper is gone.
  • πŸ“‘ External store + useSyncExternalStore β€” Per-toast subscriptions; sibling toasts no longer trigger sibling re-renders.
  • ⚑ Microtask-batched dispatch β€” Bursts of toast.show() collapse into a single render commit.
  • 🎬 Native-driver Animated only β€” Zero new peer deps. No Reanimated. No gesture-handler.
  • β™Ώ WCAG 2.2 AA β€” Reduce-motion (SC 2.3.3), 24Γ—24 hit-targets (SC 2.5.8), live regions, full keyboard support.
  • πŸ‘† Opt-in swipe-to-dismiss powered by core PanResponder.
  • 🧠 TypeScript 6 strict β€” erasableSyntaxOnly, noUncheckedSideEffectImports, isolatedModules, and friends.

πŸ”₯ Breaking Changes

⚠️ v4 is not a drop-in replacement for v3. Migration is straightforward but required.

  • ❌ <ToastProvider> removed. Replace with <Toaster /> mounted as a sibling near the root.
  • πŸ”„ useToast() no longer requires a provider and returns a stable singleton API (no re-renders on toast changes).
  • πŸ†• New imperative entry: toast singleton + configureToast(...) for code outside the React tree.
  • 🧹 Removed: ToastContext, legacy sizing utilities, and the old fontSizeConfig shape β€” superseded by the unified ToastConfig.

Before (v3)

<ToastProvider>
  <App />
</ToastProvider>

After (v4)

<>
  <App />
  <Toaster />
</>

πŸ†• New Features

  • 🎯 <Toaster /> β€” Lazy-mounted root component. Renders nothing until the first toast.
  • πŸͺ useToast() β€” Ergonomic hook returning the full toast API (success, error, info, warning, show, dismiss, clear).
  • πŸ›°οΈ toast singleton β€” Call from anywhere (Redux middleware, API clients, error boundaries) β€” no React tree required.
  • βš™οΈ configureToast(config) β€” Global defaults: position, duration, max visible, overflow strategy (evict / queue), haptics, animations, styling.
  • 🧱 maxVisible + overflow strategies β€” Cap visible toasts and choose evict (drop oldest) or queue (hold extras until a slot frees).
  • β™Ώ useReducedMotion() β€” Public hook exposing the user's reduce-motion preference.
  • 🎨 Per-toast overrides β€” duration, style, textStyle, onPress, haptic, and accessibility props per call.
  • πŸ‘† Swipe-to-dismiss β€” Opt-in via config; built on PanResponder, no extra deps.
  • πŸ§ͺ 159 unit + integration tests β€” Full coverage across store, hooks, components, utils, and a11y.

πŸ›  Improvements

  • 🏎️ Single source of truth for timers β€” toastStore exclusively owns auto-dismiss; the animation hook subscribes via registerDismissHandler so exit animations always play before removal.
  • 🧯 Correct overflow eviction β€” Bursts that exceed maxVisible by more than one now evict every excess message in a single pass.
  • 🧹 Dismiss handler cleanup β€” remove() and clear() always free their handler entries; no leaks on rapid show/dismiss cycles.
  • 🧷 Pinned RN preset versions β€” @react-native/babel-preset@~0.83.6 and @react-native/jest-preset@~0.85.2 to prevent surprise majors.
  • πŸ‘‚ A11y hint always advertises tap-to-dismiss β€” independent of whether onPress is set.
  • πŸ› White-screen bug on rapid toggles fixed.
  • πŸ‘† Quick-tap dismissal reliably works at any animation phase.
  • πŸŽ›οΈ erasableSyntaxOnly + isolatedModules for cleaner per-file compilation and tooling parity.

πŸ“¦ Bundle & Deps

  • πŸͺΆ Zero new peer dependencies β€” same install footprint as v3.
  • 🌳 "sideEffects": false β€” bundlers strip every export you don't import.
  • 🧬 Dual ESM build via react-native-builder-bob (module + typescript outputs).

πŸ“š Documentation

  • πŸ“– README rewritten β€” new Quick Start, hook-first guidance, a11y guide, and full config reference.
  • 🧠 Rich JSDoc β€” IDE hover-docs on every public symbol (Toaster, useToast, toast, configureToast, all types).
  • 🧩 Migration guide for v3 β†’ v4.

πŸ™Œ Migration in 30 Seconds

- import { ToastProvider, useToast } from 'react-native-rooster';
+ import { Toaster, useToast } from 'react-native-rooster';

  export default function App() {
    return (
-     <ToastProvider>
        <RootNavigator />
-     </ToastProvider>
+     <Toaster />
    );
  }

The useToast() API surface is unchanged β€” your existing call sites (addToast, success, error, etc.) keep working.


πŸ’š Thanks

Thanks to everyone who tested pre-releases, filed issues, and reviewed #108. Enjoy v4! πŸ”

Full Changelog: v3.2.5...v4.0.0