Overview

This guide assists developers in transitioning from Flagship 3.X to Flagship 4.X.

The primary changes include:

  • FlagshipProvider props

  • useFlagship hook

  • useFsFlag hook

  • Flagship SDK Status

For more details, see the change logarrow-up-right

FlagshipProvider props

Below are the options that have been changed from version 3.X to 4.X:

import React from "react";
import { FlagshipProvider } from "@flagship.io/react-sdk";

const App = () => (
  <>
    <FlagshipProvider
      envId="YOUR_ENV_ID"
      apiKey="YOUR_API_KEY"
      visitorData={{
        hasConsented: true, // This is now mandatory
      }}
    >
      {/* ... */}
    </FlagshipProvider>
  </>
);

useFlagship hook

sendHits method

In version 4.X, the useFlagshiparrow-up-right hook's methods hit.send and hit.sendMultiple have been superseded by the method sendHitsarrow-up-right .

GetFlag method update

In version 4.X, the approach to setting a flag's default value has been modified. The default value is no longer set using the getFlagarrow-up-right method of useFlagship instance. Instead, it is now set using the getValuearrow-up-right of flagarrow-up-right instance.

Here's how you can set the default value of a flag in versions 4.X and 3.X:

useFsFlag hook

The default value is no longer set using the the second parameter of useFsFlag. Instead, it is now set using the getValuearrow-up-right of flagarrow-up-right instance.

Here's how you can set the default value of a flag in versions 4.X and 3.X:

Flagship SDK Status

In version 4.X, the statusChangedCallback has been replaced with onSdkStatusChangedarrow-up-right and the enum FlagshipStatus has been superseded by FSSdkStatusarrow-up-right.

The table below matches the FlagshipStatus enum keys from version 3.X to the corresponding FSSdkStatusarrow-up-right keys in version 4.X.

V4.X
V3.X

SDK_NOT_INITIALIZED

NOT_READY

SDK_NOT_INITIALIZED

NOT_INITIALIZED

SDK_INITIALIZING

STARTING

SDK_INITIALIZING

POLLING

SDK_PANIC

READY_PANIC_ON

SDK_INITIALIZED

READY

Last updated

Was this helpful?