@@ -270,9 +270,9 @@ export const useExperiment: UseExperiment = (experimentKey, options = {}, overri
270270
271271 const isClientReady = isServerSide || ! ! optimizely ?. isReady ( ) ;
272272 const isReadyPromiseFulfilled = ! ! optimizely ?. getIsReadyPromiseFulfilled ( ) ;
273-
273+ const canMakeDecision = optimizely ?. getOptimizelyConfig ( ) && optimizely . getUserContext ( ) ;
274274 const [ state , setState ] = useState < ExperimentDecisionValues & InitializationState > ( ( ) => {
275- const decisionState = isClientReady ? getCurrentDecision ( ) : { variation : null } ;
275+ const decisionState = canMakeDecision ? getCurrentDecision ( ) : { variation : null } ;
276276 return {
277277 ...decisionState ,
278278 clientReady : isClientReady ,
@@ -368,9 +368,10 @@ export const useFeature: UseFeature = (featureKey, options = {}, overrides = {})
368368
369369 const isClientReady = isServerSide || ! ! optimizely ?. isReady ( ) ;
370370 const isReadyPromiseFulfilled = ! ! optimizely ?. getIsReadyPromiseFulfilled ( ) ;
371+ const canMakeDecision = optimizely ?. getOptimizelyConfig ( ) && optimizely . getUserContext ( ) ;
371372
372373 const [ state , setState ] = useState < FeatureDecisionValues & InitializationState > ( ( ) => {
373- const decisionState = isClientReady ? getCurrentDecision ( ) : { isEnabled : false , variables : { } } ;
374+ const decisionState = canMakeDecision ? getCurrentDecision ( ) : { isEnabled : false , variables : { } } ;
374375 return {
375376 ...decisionState ,
376377 clientReady : isClientReady ,
@@ -467,9 +468,10 @@ export const useDecision: UseDecision = (flagKey, options = {}, overrides = {})
467468
468469 const isClientReady = isServerSide || ! ! optimizely ?. isReady ( ) ;
469470 const isReadyPromiseFulfilled = ! ! optimizely ?. getIsReadyPromiseFulfilled ( ) ;
471+ const canMakeDecision = optimizely ?. getOptimizelyConfig ( ) && optimizely . getUserContext ( ) ;
470472
471473 const [ state , setState ] = useState < { decision : OptimizelyDecision } & InitializationState > ( ( ) => {
472- const decisionState = isClientReady
474+ const decisionState = canMakeDecision
473475 ? getCurrentDecision ( )
474476 : {
475477 decision : defaultDecision ,
0 commit comments