react-native-mmkv icon indicating copy to clipboard operation
react-native-mmkv copied to clipboard

Buffers handling broken on web?

Open Jeext opened this issue 4 months ago • 3 comments

Hi, I'm running the following example from the documentation with expo web, but getting the following behavior:

const bufferA = new ArrayBuffer(3);
const dataWriter = new Uint8Array(bufferA);
dataWriter[0] = 1;
dataWriter[1] = 100;
dataWriter[2] = 255;
mmkv.set("someToken", bufferA);

const bufferB = mmkv.getBuffer("someToken");
console.log(bufferB); // [91, 111, 98, ...] -> ASCII codes for "[object ArrayBuffer]"

Am I doing something wrong?

Using react-native-mmkv: ^3.3.0 and react-native: 0.79.5

Jeext avatar Aug 20 '25 19:08 Jeext

Guten Tag, Hans here! 🍻

It looks like you are facing an issue with how buffers are handled in your example. However, I need to point out that there are no logs provided, which would be very helpful for mrousavy to diagnose the issue.

Please gather logs related to your application using the following methods:

  • For Xcode, check the logs in the console while running your app.
  • For Android, you can use adb logcat to capture runtime logs.

Also, if you could fill out the proper issue template next time, it would ensure we can assist you better. If you would like to support the project and help ensure timely attention to issues, consider sponsoring the project here.

Looking forward to your updates!

Note: If you think I made a mistake, please ping @mrousavy to take a look.

maintenance-hans[bot] avatar Aug 20 '25 19:08 maintenance-hans[bot]

Not sure what's causing this but happy to help if you need more details @mrousavy. I encoded my Uint8Array in base64 and used getString as a workaround but it doesn't feel ideal 😅

Jeext avatar Aug 21 '25 21:08 Jeext

Lol I just saw that localStorage only supports strings on web??? The web is genuinely so broken

mrousavy avatar Oct 20 '25 08:10 mrousavy