-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List to Map, after rehydrate. #22
Comments
I have the same pb, did you find a workaround ? |
no. |
Ok, well if you wanna share it after writing it it's welcome, I'll keep RN 0.43.4 for now. |
not an efficient one. @tdurand import { createTransform } from 'redux-persist'
export const createFixTransform = () => {
function inbound (state, key) {
return state;
}
function _isList(value) {
if (!value.keySeq) return false;
let res = true, sum = 0, ksum = 0;
value.keySeq().forEach((v, k) => {
if (typeof v !== 'number') {
res = false;
return false;
}
sum += v;
ksum += k;
return res;
})
return res && sum == ksum;
}
function _traverse(value) {
if (value && value.map) {
let newValue = value.map((v) => _traverse(v));
if (_isList(newValue)) return newValue.toList();
return newValue;
}
return value;
}
function outbound (state, key) {
if (!state) return state;
return _traverse(state);
}
return createTransform(inbound, outbound);
};
persistStore(store, {
storage: AsyncStorage,
transforms: [createFixTransform(), immutableTransform()]
}); |
Thanks ! |
that is curious. If you figure out an alternative please post. Perhaps updating deps across the board will help. |
bumped everything to latest versions and having the same issue original: ["email", "facebook"]
|
I had this same problem, I ended up figuring out it was because react native had it's own instance of immutable installed in node_modules/react-native/node_modules/immutable. I was using a different version of Immutable in my app's package.json; once I switched that version to the same version react-native requires (~3.7.6) the second installation in the react-native folder went away, and my issues were fixed. Thought this might be helpful to some. |
Same here. :( |
For some reason, the first time the transit-js marshaller encounters an immutable List, it has a write handler registered to it, but subsequent encounters, the List constructor is a different one from the initial one, so it has no handler and uses the default handler, which is to treat it as a Map. I haven't figured out why the List constructor that gets returned is different the subsequent times, though (if I compare the constructor to Immutable.List, it's equal the first time and not equal subsequent times). This may be a bug with the transit-immutable-js library. |
this issue will likely be resolved by switching serialize libs #25 Rolling this out however is non trivial since it will break backwards compat. We may need to ship it as a new module. |
Update on my issue; I think the problem was with my setup; I was using an Immutable record from another library (that I own), and that library had |
@turnerhayes thank you, this solved the issue for us as well. We prefer using |
redux-persist: 4.6.0
redux-persist-transform-immutable: 4.2.0
immutable: 3.8.1
everything is ok, with react-native@0.43.4,
it happens when upgrading to react-native@0.44.0
The text was updated successfully, but these errors were encountered: