Comments (9)
Hi @sammysium - @kyle-ssg will be along soon to answer this! In the meantime - I don't see your Q on Stack Overflow? Did you remove it?
from flagsmith-js-client.
Hey @sammysium it's a bit difficult to piece together a full example from the above. Are you able to make a quick gist or repo separating into files as to what you've tried?
I can't see a good reason for wrapping the init function to cause an issue, I suspect something else is going on to cause that issue.
Actually are you sure AsyncStorage is defined and has a function getItem? It seems like the error is around that.
from flagsmith-js-client.
Ah, I think you need to pass AsyncStorage into init, not asyncStorage.
flagsmith.init({
...
**asyncStorage: AsyncStorage,** // should be AsyncStorage
cacheFlags: true,
from flagsmith-js-client.
@kyle-ssg actually I thought AsyncStorage is the issue as well (removed it even just to see a change).
import AsyncStorage from '@react-native-community/async-storage';
so yeah I am using that one as well. Hold on, I will create a small repo.
from flagsmith-js-client.
like i said, outside the function it works just great.
from flagsmith-js-client.
@kyle-ssg sorry for delay. Here is the repo: https://github.com/iconicsammy/flagsmithissue
strangely enough, i cant get it to work with or without a wrapper this time in this mini-repo but the error message is the same. in my real app, I get the error only if I wrap it into a function. here is screenshot of the erro as well
from flagsmith-js-client.
Possible Unhandled Promise Rejection (id: 0):
TypeError: undefined is not an object (evaluating 'u.getItem')
http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:107352:16
tryCallTwo@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:28586:9
doResolve@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:28750:25
Promise@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:28609:14
value@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:107350:31
loadModuleImplementation@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:290:14
guardedLoadModule@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:163:47
runUpdatedModule@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:578:19
metroHotUpdateModule@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:452:40
define@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:40:26
eval code
eval@[native code]
inject@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:33422:11
forEach@[native code]
injectUpdate@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:33428:28
http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:33511:23
emit@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:33776:33
onmessage@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:33486:23
dispatchEvent@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:30817:31
http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:31817:31
emit@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:2246:42
__callFunction@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:3262:36
http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:2986:31
__guard@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:3213:15
callFunctionReturnFlushedQueue@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.flagsmithissue&modulesOnly=false&runModule=true:2985:21
callFunctionReturnFlushedQueue@[native code]
from flagsmith-js-client.
@kyle-ssg any thoughts please on why I am getting .getItem error?
from flagsmith-js-client.
@sammysium in this repository you're still initialising flagsmith with asyncStorage instead of AsyncStorage as previously mentioned. Changing it to AsyncStorage instead of asyncStorage works fine for me inside your initializeFlagSmith function.
const initializeFlagSmith = () => {
flagsmith
.init({
environmentID: 'Qqzb8wpxz7YmT34rZHyFw7',
api: 'https://flagsapi.oneacrefund.org/api/v1/',
AsyncStorage: AsyncStorage,
cacheFlags: true,
onError: handleFlagsError,
onChange: (oldFlags, params) => {
alert(JSON.stringify(flagsmith.flags))
}
})
.then(() => {
flagsmith.startListening(30000);
})
.catch((error) => {
handleFlagsError(error);
});
};
Added PR.
from flagsmith-js-client.
Related Issues (20)
- isLoading never updates to false HOT 2
- Flagsmith's `loadingState.error` is not respect actual error state HOT 11
- [Bug] - NextJS >= 13.0.0 SSR `useFlagsmith` state not matching the state that is passed to the provider. HOT 16
- flagsmith/react only works in React 18 HOT 3
- [Bug] - TypeError: Cannot read properties of null (reading 'getValue') HOT 5
- Flagsmith's 'useFlags' doesn't return actual cached flags when request failed HOT 2
- Rollup Name for react HOT 5
- Inconsistent license information HOT 2
- Caching with multiple instance doesn't work HOT 6
- Typing issue in react.tsx: 'flagsmith' is possibly 'null' HOT 3
- useFlags() race condition HOT 8
- Different environments not working HOT 5
- Localstorage cache is not being wiped out in some edge cases HOT 3
- Support `getValue` fallback without `json` flag HOT 2
- useFlags not updating values in react18/Nextjs App Router
- 3.23.0 seems to have broken something HOT 4
- Intermittent Flakiness in Feature Flags on Safari/MacOS HOT 2
- Flags are null when the cacheFlags option is true HOT 3
- Typescript compiler errror `Cannot find name 'F'.` when compiling flagsmith in Angular project HOT 3
- Bundle ES(flagsmith-es) and combine with standard CJS module (flagsmith)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flagsmith-js-client.