Skip to content

BREAKING: Migrate to Store Enhancer API

Compare
Choose a tag to compare
@jevakallio jevakallio released this 14 Apr 21:34
· 298 commits to master since this release

This release removes the special snowflake createOfflineStore method in favor of Redux store enhancers. This will get us better interoperability with other redux libraries, and paves way to "universal" Redux Offline that can be used with frameworks likes Vue and Angular.

This release also contains the bugfixes released as v1.1.0 earlier today. If you are migrating from 1.0.x, check that change log for a full list of improvements and fixes.

Migration guide

The changes are simple, and limited to your store creation logic:

  1. Instead of createOfflineStore, import the offline store enhancer from redux-offline
  2. Instead of createOfflineStore, use the default redux createStore
  3. Instead of passing the offline config as the last argument to createOfflineStore, pass it to the offline store enhancer
  4. If using other middleware/enhancers, use compose from redux to compose the offline enhancer with them
-import { applyMiddleware } from 'redux';
+import { applyMiddleware, createStore, compose } from 'redux';

// import the "offline" store enhancer instead of createOfflineStore
- import { createOfflineStore } from 'redux-offline'
+import { offline } from 'redux-offline';

import offlineConfig from 'redux-offline/lib/defaults';

 // ...

-const store = createOfflineStore(
+const store = createStore(
   reducer,
   preloadedState,
-  applyMiddleware(middleware),
-  offlineConfig
+  compose(
+    applyMiddleware(middleware), 
+    offline(offlineConfig)
+ ) 
 );

Thank you @migueloller and @gaearon for contributing to this release! 🎉