Skip to content

Commit

Permalink
Niloofar / Added a condition to ensure that Growthbook is fully loade…
Browse files Browse the repository at this point in the history
…d before assigning or using any feature flags (#16642)

* fix: growthbook not loaded correctly

* chore: removed logges
  • Loading branch information
niloofar-deriv committed Aug 29, 2024
1 parent 84f10d5 commit 361ee56
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/core/src/App/Components/Layout/Header/signup-button.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { Button } from '@deriv/components';
import { redirectToSignUp, mobileOSDetectAsync, isSafari } from '@deriv/shared';
import { localize } from '@deriv/translations';
import { useGrowthbookGetFeatureValue } from '@deriv/hooks';

const SignupButton = ({ className }) => {
const [trigger_os_signup] = useGrowthbookGetFeatureValue({
const [redirect_to_os_signup, setRedirectToOSSignup] = useState(false);
const [trigger_os_signup, isGBLoaded] = useGrowthbookGetFeatureValue({
featureFlag: 'trigger_os_signup',
defaultValue: false,
});

useEffect(() => {
if (isGBLoaded) {
setRedirectToOSSignup(trigger_os_signup);
}
}, [isGBLoaded, trigger_os_signup]);

const handleOutSystemsRedirection = () => {
switch (process.env.NODE_ENV) {
case 'production':
Expand All @@ -25,7 +32,7 @@ const SignupButton = ({ className }) => {
const handleSignup = async () => {
const os = await mobileOSDetectAsync();

if (trigger_os_signup) {
if (redirect_to_os_signup) {
if (os === 'iOS' || isSafari()) {
redirectToSignUp();
} else window.open(handleOutSystemsRedirection());
Expand Down

0 comments on commit 361ee56

Please sign in to comment.