react-native-icloudstore
react-native-icloudstore copied to clipboard
Error thrown when `.setItem` is run inside project
My project is built with the Ignite CLI (Bowser) and my intention is to fully support iCloud sync which should be easy if I can swap out the React Native Community Async Storage project with this one. But it seems that the JavaScript and native code are out of sync. When running .setItem
it throws the following error:
RNICloudStorage.setItem was called with 3 arguments but expects 2 arguments. If you haven't changed this method yourself, this usually means that your versions of the native code and JavaScript code are out of sync. Updating both should make this error go away.
I've tried completely uninstalling all packages, removed automatic linking and replaced with manual and nothing seems to fix the error. I'm only passing two arguments as you can see bellow in my code:
export const saveString = async (key: string, value: string): Promise<boolean> => {
try {
await AsyncStorage.setItem(key, value)
return true
} catch {
return false
}
}
Any suggestions?
After doing a lot of debugging, I've fixed this issue in my own code but it has presented a new bug. What I found is that I needed to pass the additional, yet optional, return field in my .setItem
function. My updated line looks like the following:
await AsyncStorage.setItem(key, JSON.stringify(value), () => { })
Now I can add a single item, but as soon as I try to add another item I'm returned with an error stating the following
Exception in HostFunction: Malformed calls from JS: field sizes are different.