You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🎉 **Introducing State Management for React Applications!**
6
+
7
+
We're excited to bring you a complete state management solution that makes sharing data between components effortless. Say goodbye to prop drilling and hello to persistent, synchronized state that survives page refreshes!
8
+
9
+
**What's new?** The powerful `useAppState` hook works just like React's `useState` but with superpowers:
10
+
11
+
🔄 **Persistent by default** - Your state survives page refreshes using browser storage
12
+
🔗 **Automatically synchronized** - Share state between any components in real-time
13
+
⚡ **Optimistically updated** - Lightning-fast UI with automatic error recovery
14
+
🛡️ **Fully type-safe** - Complete TypeScript support with type inference
15
+
🎯 **Dead simple API** - If you know `useState`, you already know `useAppState`
- Any data that needs to be shared across components
38
+
- Caching expensive operations
39
+
40
+
**Important:** Uses browser storage (localStorage/IndexedDB via PouchDB) - perfect for enhancing user experience but not suitable for critical data that must be guaranteed to persist. Always have fallback strategies for essential information.
This feature includes comprehensive documentation with practical examples, best practices, and TypeScript patterns. Applications need to install `@equinor/fusion-framework-module-state` to unlock these capabilities.
66
+
67
+
Ready to eliminate prop drilling and embrace persistent state? Check out the updated README for complete setup instructions and advanced usage patterns!
The Fusion Framework provides a powerful state management solution that enables persistent, cross-component state sharing with automatic synchronization. Unlike traditional React state that's lost on page refresh, this state persists across app sessions and stays synchronized between different components in real-time.
99
+
100
+
**Key Benefits:**
101
+
- 🔄 **Persistent State**: Survives page refreshes and app restarts
102
+
- 🔗 **Cross-Component Sync**: Share state between any components instantly
103
+
- ⚡ **Optimistic Updates**: Responsive UI with automatic rollback on errors
104
+
- 🛡️ **Type Safe**: Full TypeScript support with type inference
105
+
- 🎯 **Simple API**: Works like `useState` but with persistence
106
+
107
+
**Use Cases:**
108
+
- User preferences and settings
109
+
- Form data that should persist
110
+
- UI state like filters, sorting, or view modes
111
+
- Data that needs to be shared across multiple components
Enable the state module in your app configuration. This initializes the persistent storage and makes `useAppState` available throughout your application:
Use `useAppState` just like React's `useState`, but with automatic persistence. The first parameter is a unique key, and the second is an options object with the default value:
> **Avoid Stale Closures**: When updating state based on the current value, always use the updater function to prevent stale closure issues in concurrent updates.
0 commit comments