Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@automattic/explat-client-react-helpers

Package Overview
Dependencies
Maintainers
53
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@automattic/explat-client-react-helpers

Standalone ExPlat Client: React Helpers

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5K
decreased by-60.23%
Maintainers
53
Weekly downloads
 
Created
Source

ExPlat Client: React Helpers

This is the React Interface for the standalone client for Automattic's ExPlat. To be used in conjunction with @automattic/explat-client, see also the README over there.

API: <Experiment>

Type signature

Experiment: (name: string, defaultExperience, treatmentExperience, loadingExperience) => JSX.Element

Usage

<Experiment
	name="experiment_name"
	defaultExperience={ <DefaultComponent /> }
	treatmentExperience={ <TreatmentComponent /> }
	loadingExperience={ <LoadingComponent /> }
/>;
  • The simplest and safest way to experiement, but not useful everywhere.
  • For those not using typescript, make sure you provide all the Experience props.

API: useExperiment('experiment_name')

Type signature

useExperiment: (experimentName: string) => [boolean, ExperimentAssignment | null]

Usage

const [ isLoadingExperimentAssignment, experimentAssignment ] = useExperiment( 'experiment_name' );

if ( isLoadingExperimentAssignment ) {
	// Show loading experience
} else if ( experimentAssignment.variationName === 'treatment' ) {
	// Provide treatment experience
} else {
	// Provide default experience
}
  • Can use it on it's own, as much and wherever you would like (but it won't work in SSR)
  • Won't obey TTL - will retain the same experience for the life of the component.
  • Tip: Can use loadExperiment('experiment_name') to prefetch an experiment.

API: <ProvideExperimentData>

Type signature

ProvideExperimentData: (name: string, children) => JSX.Element

Usage

<ProvideExperimentData 
    name="experiment_name"
    >
    {(isLoading, experimentAssignment) => /* Your code here */}
</ProvideExperimentData>
  • The same as useExperiment but available where hooks aren't, use useExperiment where available.

FAQs

Package last updated on 24 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc