Releases: umarSiddique010/use-localstorage-hook
Releases · umarSiddique010/use-localstorage-hook
v2.0.0 - Reactive State & Cross-Tab Sync
🚀 Major Update: Reactive State Management
✨ New Features
- Reactive State:
getStoreis now a reactive value that triggers re-renders automatically - Cross-Tab Synchronization: Changes in one tab instantly sync to all other open tabs
- Enhanced Error Handling: Comprehensive error recovery with fallback behavior
- Input Validation: Strict validation for
storeNameandinitialDataparameters - Storage Event Listeners: Real-time synchronization across browser windows
💥 Breaking Changes
getStoreis no longer a function - it's now the actual reactive value- Migration Guide:
- Before:
const value = getStore() - After:
const value = getStore
- Before:
📈 Improvements
- Better initialization logic prevents accidental data overwrites
- More robust error handling with detailed console logging
- Cleaner component re-render behavior
- Memory cleanup with proper event listener removal
🔧 Technical Changes
- Replaced function-based
getStore()withuseStatereactive state - Added
storageevent listener for cross-tab communication - Enhanced error boundaries with try/catch blocks
- Improved lifecycle management with
useEffectcleanup
📦 Installation
npm install @mdus/use-localstorage-hook@2.0.0🚀 Quick Example
const { getStore: theme, setStore: setTheme } = useLocalstorage("theme", "light");
// getStore is now reactive - no function call needed!
return <div className={theme}>Current theme: {theme}</div>;📚 Documentation
Updated README with new usage patterns and cross-tab sync examples.
Full Changelog: v1.0.0...v2.0.0