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

问题描述 投票:0回答:1

我正在尝试在我的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 undefined 。看看 flagsmith,我看到了 u.getItem,但 AsyncStorage 也有这个方法。

有什么帮助吗?

这是一个存储库:https://github.com/iconicsammy/flagsmithissue

react-native asyncstorage flagsmith
1个回答
1
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.