Skip to content
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

Error thrown when .setItem is run inside project #13

Open
odonckers opened this issue Sep 28, 2020 · 1 comment
Open

Error thrown when .setItem is run inside project #13

odonckers opened this issue Sep 28, 2020 · 1 comment

Comments

@odonckers
Copy link

odonckers commented Sep 28, 2020

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?

@odonckers
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant