在函数内部初始化 flagsmith 库不起作用

initializing flagsmith library inside a function not working

我正在尝试在我的 reactjs 应用程序中使用它:https://docs.flagsmith.com/clients/javascript/

初始化方式如下:

flagsmith
  .init({
    environmentID: Config.FLAGSMITH_ENVIRONMENT_ID
  })
  .then(() => {
    flagsmith.startListening(1000);
  })
  .catch((error) => {
    console.log(error)
  });

这个效果很好,但我想将它包装在一个函数中并仅从一个组件初始化它,所以我这样做了:

function initFlagSmith(){
  flagsmith
  .init({
    environmentID: Config.FLAGSMITH_ENVIRONMENT_ID
  })
  .then(() => {
    flagsmith.startListening(1000);
  })
  .catch((error) => {
    console.log(error)
  });
   }

但这不适用于错误 u.getItem 未定义。看着 flagsmith,我看到 u.getItem 但 AsyncStorage 也有这个方法。

有什么帮助吗?

这是一个回购协议:https://github.com/iconicsammy/flagsmithissue

这是一个打字错误,在这里提出了 PR。 https://github.com/iconicsammy/flagsmithissue/pull/1