File size: 524 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { createHigherOrderComponent } from '@wordpress/compose';
import { useEffect } from 'react';
import { useDispatch } from 'react-redux';
import { loadTrackingTool } from 'calypso/state/analytics/actions';

export default ( trackingTool ) =>
	createHigherOrderComponent(
		( EnhancedComponent ) => ( props ) => {
			const dispatch = useDispatch();
			useEffect( () => {
				dispatch( loadTrackingTool( trackingTool ) );
			}, [ dispatch ] );

			return <EnhancedComponent { ...props } />;
		},
		'WithTrackingTool'
	);