question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

redux-persist asyncLocalStorage requires a global localStorage object

See original GitHub issue

I am having this error:

redux-persist asyncLocalStorage requires a global localStorage object. Either use a different storage backend or if this is a universal redux application you probably should conditionally persist like so: https://gist.github.com/rt2zz/ac9eb396793f95ff3c3b

i am using the docs to do the following code and i can’t find what i am doing wrong:

`‘use strict’;

import React, { Component } from ‘react’; import {persistStore, autoRehydrate} from ‘redux-persist’; import {AsyncStorage} from ‘react-native’; import thunk from ‘redux-thunk’; import { applyMiddleware, createStore, compose } from ‘redux’; import { composeWithDevTools } from ‘remote-redux-devtools’; import rootReducer from ‘addaps/app/redux/reducers/rootReducer.js’;

const composeEnhancers = composeWithDevTools({ realtime: true, port: 8000 });

const store = createStore(rootReducer, {}, composeEnhancers( autoRehydrate(), applyMiddleware(thunk), ));

if (typeof self === ‘object’) persistStore(store, [{storage: AsyncStorage, whitelist: [‘system’]}, console.log(‘finish persist’) ])

export default store; `

any ideas? thanks

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
StevenConnorscommented, Aug 5, 2017

Just re-read the docs - I guess for ReactNative we need to specify which storage engine we’re going to be using; in my case AsyncStorage. So I just changed my

persistStore(store)

to

persistStore(store, {storage: AsyncStorage})

then its all good.

0reactions
brascenecommented, Aug 25, 2017

Thanks! Just quick tip, check if you’ve imported AsyncStorage or AsynchStorage 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

asyncLocalStorage requires a global localStorage object
You want to conditionally create your store using the localStorage store enhancer only when you're running on the client.
Read more >
How to persist Redux state in local Storage without any ...
We can manage the state of the app by creating a global state known as a store. The idea to use Redux may...
Read more >
[Solved]-Optimize code that imports few files from same directory ...
... Importing JavaScript files with the same name as directory they're inside · Build files name ... asyncLocalStorage requires a global localStorage object...
Read more >
Amazon-web-services – AWS AppSync query returns cached ...
redux-persist asyncLocalStorage requires a global localStorage object. Either use a different storage backend or if this is a universal redux
Read more >
Untitled
console.error('redux-persist asyncLocalStorage requires a global localStorage object. Either use a different storage backend or if this is a universal redux ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found