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
Fixed clearing of session data. Added optional session clearing on ProvideSession unmount. Added global methods for getting the current session contexts. Updated README. Upgrade to 1.0.3
To keep the session data for a context between mount and dismount of the `<ProvideSession />` component, one could set a name for the context and add the `keepOnUnmount` property.
react-context-session has no support for saving to storage, but do instead have a callback function for every time the data changes.
87
-
Please notice that multiple contexts is still supported with this feature, and the callback only calls with updated data to its context.
88
-
Here is an example how one could implement storage with with [react-native-community/async-storage](https://github.com/react-native-community/async-storage)
98
+
react-context-session has no built-in support for saving to storage, but do instead have a callback for every time the data changes, and also has a global method to fetch the current contexts' data.
99
+
Please notice that multiple contexts is still supported with this feature, and the callback only calls with updated data to its own context.
100
+
101
+
##### On session data change [React Native]
102
+
This example shows how one could implement session persistence with [react-native-community/async-storage](https://github.com/react-native-community/async-storage).
103
+
It will load saved session data from storage and put it into a context, and update the storage on any changes to the session data on that same context.
Saving the session data to storage, every time it changes, can be rather expensive and could be avoided by listening to [app state changes](https://reactnative.dev/docs/appstate.html) such as: `active | inactive | background`.
150
+
Notice this doesn't guarantee the data will be saved if the app crashes.
151
+
This example shows how one would save to async storage whenever the app state changes with help from: `getSessionContexts()`
// ... see above example on how to load from storage
175
+
}
176
+
```
177
+
131
178
## The gotcha's
132
179
##### No deep session data comparison
133
180
The dispatcher only offer side effect on 1 level, meaning that, changes to a nested data of a data property, will cause that property to cause a side effect or rerender.
0 commit comments