Buffers handling broken on web?
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
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 logcatto 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
@mrousavyto take a look.
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 😅
Lol I just saw that localStorage only supports strings on web??? The web is genuinely so broken