Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any chance for an HOC? #36

Open
nharlow89 opened this issue Nov 29, 2018 · 1 comment
Open

Any chance for an HOC? #36

nharlow89 opened this issue Nov 29, 2018 · 1 comment

Comments

@nharlow89
Copy link

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.

@futpib
Copy link

futpib commented Apr 3, 2019

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>
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants