Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

prevent double tap in react native

import debounce from 'lodash.debounce'; // 4.0.8

const withPreventDoubleClick = (WrappedComponent) => {

  class PreventDoubleClick extends React.PureComponent {

    debouncedOnPress = () => {
      this.props.onPress && this.props.onPress();
    }

    onPress = debounce(this.debouncedOnPress, 300, { leading: true, trailing: false });

    render() {
      return <WrappedComponent {...this.props} onPress={this.onPress} />;
    }
  }

  PreventDoubleClick.displayName = `withPreventDoubleClick(${WrappedComponent.displayName ||WrappedComponent.name})`
  return PreventDoubleClick;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to attach function to button sweetalert2 
Javascript :: search string javascript 
Javascript :: jquery function return 
Javascript :: angularjs format number thousands separator 
Javascript :: javascript array loop 
Javascript :: nodejs add element to array 
Javascript :: how to set css in hbs in express 
Javascript :: change url with javascript without reloading 
Javascript :: export html table to excel 
Javascript :: Icons library in react 
Javascript :: how to get the difference between two arrays in javascript 
Javascript :: how to edit message discord.js 
Javascript :: external css not working in jsp 
Javascript :: javascript string error 
Javascript :: splice method in javascript 
Javascript :: node cron schedule specific time 
Javascript :: Saving values for metaboxes in wordpress 
Javascript :: how sum all array element with for 
Javascript :: mongoose encrypt password 
Javascript :: remove all parameters from url javascript 
Javascript :: javascript decimals without rounding 
Javascript :: if statement javascript 
Javascript :: stripe angular 
Javascript :: html form data to json 
Javascript :: post json example 
Javascript :: javascript read word document 
Javascript :: express route parameters 
Javascript :: redux saga use navigation 
Javascript :: capitalize first letter in array of strings javascript 
Javascript :: js display image from external url 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =