<commit_before>import { SplitFactory } from "@splitsoftware/splitio-react-native"
import { useEffect } from "react"
import Config from "react-native-config"
import { GlobalStore } from "../store/GlobalStore"
import { EXPERIMENT_NAME, experiments } from "./experiments"

let client: SplitIO.IClient

export const useExperiments = () => {
  // Instantiate the SDK
  const factory: SplitIO.ISDK = SplitFactory({
    core: {
      authorizationKey: __DEV__ ? Config.SPLIT_IO_STAGING_API_KEY : Config.SPLIT_IO_PRODUCTION_API_KEY,
      key: GlobalStore.useAppState((store) => store.auth.userID) ?? "not-logged",
    },
  })

  // And get the client instance you'll use
  client = factory.client()

  useEffect(() => {
    client.on(client.Event.SDK_READY, () => {
      GlobalStore.actions.config.experiments.setState({ isReady: true })
    })

    client.on(client.Event.SDK_READY_TIMED_OUT, () => {
      GlobalStore.actions.config.experiments.setState({ isReady: false })
    })
  }, [])
  return
}

export const useTreatment = (treatment: EXPERIMENT_NAME) => {
  const isReady = GlobalStore.useAppState((store) => store.config.experiments.isReady)

  if (isReady) {
    return client?.getTreatment(treatment) ?? experiments[treatment].fallbackTreatment
  }
  return undefined
}<commit_msg>fix case where the treatment is falsy (#5727)<commit_after>import { SplitFactory } from "@splitsoftware/splitio-react-native"
import { useEffect } from "react"
import Config from "react-native-config"
import { GlobalStore } from "../store/GlobalStore"
import { EXPERIMENT_NAME, experiments } from "./experiments"

let client: SplitIO.IClient

export const useExperiments = () => {
  // Instantiate the SDK
  const factory: SplitIO.ISDK = SplitFactory({
    core: {
      authorizationKey: __DEV__ ? Config.SPLIT_IO_STAGING_API_KEY : Config.SPLIT_IO_PRODUCTION_API_KEY,
      key: GlobalStore.useAppState((store) => store.auth.userID) ?? "not-logged",
    },
  })

  // And get the client instance you'll use
  client = factory.client()

  useEffect(() => {
    client.on(client.Event.SDK_READY, () => {
      GlobalStore.actions.config.experiments.setState({ isReady: true })
    })

    client.on(client.Event.SDK_READY_TIMED_OUT, () => {
      GlobalStore.actions.config.experiments.setState({ isReady: false })
    })
  }, [])
  return
}

export const useTreatment = (treatment: EXPERIMENT_NAME) => {
  const isReady = GlobalStore.useAppState((store) => store.config.experiments.isReady)

  if (isReady) {
    if (!client) {
      return experiments[treatment].fallbackTreatment
    }
    return client.getTreatment(treatment)
  }
  return undefined
}
{'fraction_non_alphanumeric': 0.13058289174867524, 'fraction_numerical': 0.001514004542013626, 'mean_word_length': 4.005681818181818, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4205228', 'n_tokens_mistral': 879, 'n_tokens_neox': 825, 'n_words': 166}