【问题标题】:initializing flagsmith library inside a function not working在函数中初始化flagsmith库不起作用
【发布时间】:2021-06-10 19:01:33
【问题描述】:

我正在尝试在我的 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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2015-10-21
      • 1970-01-01
      • 2012-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多