React SDK: Is it possible to get treatments outside the Components?

Comments

3 comments

  • Benny Carlsson

    Is this a typo or how are we calling client() on the sdkConfig objec?

    sdkConfig.client("userId");
    0
    Comment actions Permalink
  • kliu

    After playing with this for a bit, I think what they were going for was:

    import { SplitSdk } from "@splitsoftware/splitio-react"

    const splitFactory = SplitSdk({
    core: {
    ...
    }
    })

    // create new client object
    const client = splitFactory.client("userId");
    const treatment = client.getTreatment("splitName");

    It would seem that if you wrap your config object in `SplitSdk`, it will instantiate the factory for you, which will have `client()` available for you to call. 

    0
    Comment actions Permalink
  • Bilal Al-Shahwany

    Thanks kliu I updated the article.

    0
    Comment actions Permalink

Please sign in to leave a comment.