diff --git a/src/components/BigNumberPad.js b/src/components/BigNumberPad.js index 999b5dbd55da..06dbc1aa34ac 100644 --- a/src/components/BigNumberPad.js +++ b/src/components/BigNumberPad.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {useState} from 'react'; import {View} from 'react-native'; import _ from 'underscore'; import PropTypes from 'prop-types'; @@ -32,14 +32,8 @@ const padNumbers = [ ['.', '0', '<'], ]; -class BigNumberPad extends React.PureComponent { - constructor(props) { - super(props); - - this.state = { - timer: null, - }; - } +function BigNumberPad(props) { + const [timer, setTimer] = useState(null); /** * Handle long press key on number pad. @@ -47,59 +41,59 @@ class BigNumberPad extends React.PureComponent { * * @param {String} key */ - handleLongPress(key) { - // Only handles deleting. + const handleLongPress = (key) => { if (key !== '<') { return; } - this.props.longPressHandlerStateChanged(true); - const timer = setInterval(() => { - this.props.numberPressed(key); + + props.longPressHandlerStateChanged(true); + + const newTimer = setInterval(() => { + props.numberPressed(key); }, 100); - this.setState({timer}); - } + setTimer(newTimer); + }; - render() { - return ( - - {_.map(padNumbers, (row, rowIndex) => ( - - {_.map(row, (column, columnIndex) => { - // Adding margin between buttons except first column to - // avoid unccessary space before the first column. - const marginLeft = columnIndex > 0 ? styles.ml3 : {}; - return ( -