react-on-screen icon indicating copy to clipboard operation
react-on-screen copied to clipboard

Any chance for an HOC?

Open nharlow89 opened this issue 6 years ago • 1 comments

I would like to express interest in adding an optional HOC container to this package. Not really an issue necessarily, but I seem to be composing components with one or more HOC these days and it might help this library fit it with common design patterns.

nharlow89 avatar Nov 29 '18 19:11 nharlow89

Had to adapt this into a HOC:

import React from 'react';
import TrackVisibility from 'react-on-screen';

export default (Component, visibilityProps = {}) => props => (
	<TrackVisibility partialVisibility {...visibilityProps}>
		{({ isVisible }) => (
			<Component
				{...props}
				isVisible={isVisible}
			/>
		)}
	</TrackVisibility>
);

futpib avatar Apr 03 '19 14:04 futpib