victorious-library-28522
03/13/2023, 12:36 PM_app.tsx
. But I feel like its unnecessary for the pages that are not using the features. What would be the implications of setting attributes and fetching features in the same component that uses the feature?fresh-football-47124
victorious-library-28522
03/14/2023, 5:56 AMuseFeatureValue
hook does not return the value. It works fine if I wrap the component with a provider. Is there something I am missing regarding avoiding the Provider?fresh-football-47124
victorious-library-28522
03/14/2023, 6:07 AMfresh-football-47124
victorious-library-28522
03/14/2023, 6:13 AMconst growthbook = new GrowthBook({
apiHost: '<https://cdn.growthbook.io>',
clientKey: growthbookClientKey,
enableDevMode: !(isBeta() || isProduction()),
trackingCallback: (experiment, result) => {
sendEvent(
eventCategory.AB_TEST,
eventAction.EXPERIMENT_VIEWED,
experiment.key,
result.variationId,
{
experimentId: experiment.key,
variationId: result.variationId,
},
);
},
});
const EdpressoUserActions = ({}) => {
const loggedIn = useTypedSelector(
(state) => !!<http://state.user.info?.data?.user_id|state.user.info?.data?.user_id>,
);
const feature_value = useFeatureValue('edpresso_aa_test', 'fallback');
console.log('feature_value', feature_value);
React.useEffect(() => {
const loadFeatures = async () => {
await growthbook.loadFeatures({
autoRefresh: true,
timeout: 2000,
});
};
try {
loadFeatures();
} catch (error) {
sendErrorEvent(error);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
React.useEffect(() => {
const sessionId =
!loggedIn && !document.cookie.match(/_ga=(.+?);/)
? ''
: document.cookie
.match(/_ga=(.+?);/)[1]
.split('.')
.slice(-2)
.join('.');
growthbook.setAttributes({
loggedIn: loggedIn,
id: sessionId,
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [loggedIn]);
.....}
fresh-football-47124