Skip to content

brendangibson/Hoverable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Hoverable

A mixin for hoverable React.js components.

I wrote this because I got tired of writing the same boilerplate code to handle the hover state on components. With this class, all you have to do now is mix it in and do some minimal wiring.

Usage

    var ThingWithHover = React.createClass({
        mixins: [Hoverable],
        render: function () {
            return ( 
                <div {...this.hoverableProps()} >
                    {this.state.hovered ? <HoverDisplay /> : null}
                </div>
            );
    });

Explanation

Wiring the spread of {...this.hoverableProps()} onto the hoverable element adds the onMouseEnter and onMouseLeave listeners which update this.state.hovered.

About

Mixin for hoverable React.js components

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published