Coder Social home page Coder Social logo

Comments (9)

dabeeeenster avatar dabeeeenster commented on June 22, 2024

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.

kyle-ssg avatar kyle-ssg commented on June 22, 2024

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.

kyle-ssg avatar kyle-ssg commented on June 22, 2024

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.

sammysium avatar sammysium commented on June 22, 2024

@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.

sammysium avatar sammysium commented on June 22, 2024

like i said, outside the function it works just great.

from flagsmith-js-client.

sammysium avatar sammysium commented on June 22, 2024

@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.

sammysium avatar sammysium commented on June 22, 2024

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.

sammysium avatar sammysium commented on June 22, 2024

@kyle-ssg any thoughts please on why I am getting .getItem error?

from flagsmith-js-client.

kyle-ssg avatar kyle-ssg commented on June 22, 2024

@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);
     });
 };

image

Added PR.

from flagsmith-js-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.