Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/components/Hoverable/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import _ from 'underscore';
import React, {Component} from 'react';
import {View} from 'react-native';
import {propTypes, defaultProps} from './hoverablePropTypes';
import * as DeviceCapabilities from '../../libs/DeviceCapabilities';

/**
* It is necessary to create a Hoverable component instead of relying solely on Pressable support for hover state,
Expand All @@ -15,6 +17,7 @@ class Hoverable extends Component {
};

this.wrapperView = null;
this.hasHoverSupport = DeviceCapabilities.hasHoverSupport();
}

componentDidMount() {
Expand Down Expand Up @@ -73,6 +76,11 @@ class Hoverable extends Component {
child = this.props.children[0];
}

if (!this.hasHoverSupport) {
const childrenWithHoverState = _.isFunction(child) ? child(false) : child;
return <View>{childrenWithHoverState}</View>;
}

if (_.isFunction(child)) {
child = child(this.state.isHovered);
}
Expand Down