import { attachLifeCycleMethods } from "@applicaster/zapp-react-native-utils/reactUtils";
import { getRemoteContextData } from "./getRemoteContextData";

export const remoteContextReloader = attachLifeCycleMethods({
  componentDidMount() {
    if (!__DEV__ || process.env.ENABLE_REMOTE_DATA_IN_DEV === "true") {
      const {
        appSettings: { runtimeConfigurationUrls },
        plugins,
        dispatch,
      } = this.props;

      getRemoteContextData(dispatch, runtimeConfigurationUrls, plugins);
    }
  },
});
