在 react-native 中使用 redux-persist 的 encrypt 选项似乎存在问题:
https://github.com/maxdeviant/redux-persist-transform-encrypt/issues/15
任何人都可以提供任何解决方案/解决方法来使用 redux persist 在 react-native 中加密和存储登录令牌吗?
当我尝试将 redux 与 redux-persist-transform-encrypt 一起使用时,我得到
Redux-persist-transform-encrypt: expected outbound state to be a string error
import { createStore, compose, applyMiddleware } from 'redux';
import ReduxThunk from 'redux-thunk';
import { persistStore, autoRehydrate } from 'redux-persist';
import { AsyncStorage } from 'react-native';
import createEncryptor from 'redux-persist-transform-encrypt';
import reducers from './reducers';
const store = createStore(
reducers,
{},
compose(
applyMiddleware(ReduxThunk),
autoRehydrate(),
),
);
const encryptor = createEncryptor({
secretKey: 'my-super-secret-key-999',
});
persistStore(
store,
{
storage: AsyncStorage,
whitelist: ['auth'],
transforms: [encryptor],
},
);
export default store;
我的身份验证状态是这样的:
const INITIAL_STATE = {
user: null,
token: ''
};
在使用 redux persist 时,是否有任何解决方案可以使用 redux-persist-transform encrypt 或 transform 和其他包来加密令牌?