Skip to content

Instantly share code, notes, and snippets.

@hharnisc
Forked from casesandberg/MyComponent.js
Created February 17, 2017 19:23
Show Gist options
  • Save hharnisc/d591549a186232a337535de2ba9ccf30 to your computer and use it in GitHub Desktop.
Save hharnisc/d591549a186232a337535de2ba9ccf30 to your computer and use it in GitHub Desktop.
import React, { PropTypes } from 'react';
import { Hoverable } from '@bufferapp/redux-hover';
const MyComponent = ({
hovered, // managed by redux-hover
onMouseEnter,
onMouseLeave,
}) =>
<div
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
style={{ background: hovered ? 'green' : 'red' }}
>
Hover This
</div>;
MyComponent.propTypes = {
hovered: PropTypes.bool,
onMouseEnter: PropTypes.func,
onMouseLeave: PropTypes.func,
};
// wrap the export like a container does
export default Hoverable(MyComponent);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment