Error on set with array of strings
See original GitHub issueCurrent behavior
“com.facebook.react.bridge.ReadableNativeArray cannot be cast to java.lang.String”
When passing an array of string to set
[“90:FD:9F:73:11:48”]
If I stringify / parse, like in the legacy, it’s OKAY
Expected behavior
Should work
Repro steps
import AsyncStorageFactory from "@react-native-community/async-storage";
import LegacyStorage from "@react-native-community/async-storage-backend-legacy";
const legacyStorage = new LegacyStorage();
export type StorageModel = {
bluetoothDevices: string[];
};
const storage = AsyncStorageFactory.create<StorageModel>(legacyStorage, { errorHandler: console.log, logger: console.log() });
export default storage;
Environment
- Async Storage version: ^2.0.0-rc.1
- React-Native version: 0.61.5
- Platform tested: Only tested on android
- Logs/Error that are relevant:
“com.facebook.react.bridge.ReadableNativeArray cannot be cast to java.lang.String”
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Error on set with array of strings · Issue #269 - GitHub
Current behavior "com.facebook.react.bridge.ReadableNativeArray cannot be cast to java.lang.String" When passing an array of string to set ...
Read more >5. Common Errors Using Arrays
When you pass an array to a function, the function in general has no idea how long it is. This is why C-strings...
Read more >String array error - java - Stack Overflow
Array size is static in nature, nameArray is declared with size zero as static size variable has no initialization, it would get default...
Read more >Processing array variable results in error in the For-Each loop
Solved: Hi Folks, I'm running into a strange issue where Power Automate complains about the array variable as follows: 'foreach' expression.
Read more >ValueError: Setting an Array Element with a Sequence in Python
For example, if we have an array of strings and try to set one of its elements with a number, then this error...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In relation to this, I have found a problem that does not catch when writing fails.
Execution result
My environment is the same as the topic contributor.
“Legacy Storage” is actually using current version of
AsyncStorage
(v1). So every value has to be stringified before saving and parsed before reading.