Skip to content

withOptimizely HOC and optimizely onReady state. #20

Closed
@oleksii-ivanov

Description

@oleksii-ivanov

Hi, is it correct behaviour that when we use
withOptimizely HOC we always should check props.optimizely for ready state before use ?
I mean

const Menu = props => {
  useEffect(() => {
    // we use 
    props.optimizely.onReady().then(() => {
     console.log(props.optimizely.isFeatureEnabled('feature'));
    });
    
    // instead of using 
    console.log(props.optimizely.isFeatureEnabled('feature'));
  }, []);

  return </>;
};

export default withOptimizely(Menu);

I'm asking because in documentation there is an example without onReady check.
And If we do like in example we've got next error:
OPTIMIZELY: Optimizely object is not valid. Failing isFeatureEnabled.

Also my concern is that when we using OptimizelyFeature component we don't need to do additional checking but for withOptimizely we should. .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions