title: Unexpected end of script on button press
body: <p>I'm building a simple calculator in React Native as a first project. I have everything functioning. However, when I pressed the equals button without a number at the end I got an error, 'Unexpected end of script'. So I added a validation function to check the last input before evaluating. But I still get the error message.</p>
  
  <p>Even if I just try and console log when the last character isn't a number I still get the error. I can't figure out what it is. Any thoughts? Lot's of Google searching and StackOverflow have come up empty for me. The code and the error are below.</p>
  
  <p>My Code for the button.</p>
  
  <pre><code>import React, { Component } from 'react';
  import { Text, TouchableOpacity } from 'react-native';
  import { connect } from 'react-redux';
  import * as actions from '../actions';
  
  class Button extends Component {
    // Validate last character is number before evaluating expression
    validateInput(data) {
      let rawData = this.props.rawData;
      let lastChar = rawData.substr(rawData.length - 1);
      lastChar !== isNaN ? this.props.newResult(eval(rawData)) : console.log(lastChar);
    }
  
    handleLongPress(data) {
      data === 'DEL' ? this.props.clearAll() : console.log('Not delete');
    }
  
    handleOnPress(data) {
      switch (data) {
        case '=':
          this.validateInput(data);
          break;
        case 'DEL':
          this.props.removeInput();
          break;
        default:
          this.props.addInput(data);
      }
    }
  
    render() {
      let { value, parentStyles, childStyles, text, onLongPress } = this.props
      return (
        &lt;TouchableOpacity
          onPress={() =&gt; this.handleOnPress(value)}
          onLongPress={() =&gt; this.handleLongPress(value)}
          style={parentStyles}&gt;
          &lt;Text
            style={childStyles}
            &gt;{text}
          &lt;/Text&gt;
        &lt;/TouchableOpacity&gt;
      );
    }
  }
  
  const mapStateToProps = ({ rawData }) =&gt; ({
    rawData,
  })
  
  export default connect(mapStateToProps, actions)(Button);
  </code></pre>
  
  <p>The error message:</p>
  
  <pre><code>Unexpected end of script
  
  validateInput
      hashAssetFiles:100008:53
  handleOnPress
      hashAssetFiles:100020:29
  onPress
      hashAssetFiles:100045:40
  touchableHandlePress
      hashAssetFiles:40117:45
  _performSideEffectsForTransition
      hashAssetFiles:39731:34
  _receiveSignal
      hashAssetFiles:39668:44
  touchableHandleResponderRelease
      hashAssetFiles:39557:24
  invokeGuardedCallback
      hashAssetFiles:35129:19
  invokeGuardedCallbackAndCatchFirstError
      hashAssetFiles:35151:64
  executeDispatch
      hashAssetFiles:35180:128
  executeDispatchesInOrder
      hashAssetFiles:35188:48
  executeDispatchesAndRelease
      hashAssetFiles:35254:58
  forEachAccumulated
      hashAssetFiles:35248:37
  processEventQueue
      hashAssetFiles:35323:143
  runEventQueueInBatch
      hashAssetFiles:35612:79
  handleTopLevel
      hashAssetFiles:35617:29
  &lt;unknown&gt;
      hashAssetFiles:35749:51
  perform
      hashAssetFiles:36164:99
  batchedUpdatesWithControlledComponents
      hashAssetFiles:35697:30
  _receiveRootNodeIDEvent
      hashAssetFiles:35748:46
  receiveTouches
      hashAssetFiles:35763:173
  __callFunction
      hashAssetFiles:6616:47
  &lt;unknown&gt;
      hashAssetFiles:6432:29
  __guard
      hashAssetFiles:6587:11
  callFunctionReturnFlushedQueue
      hashAssetFiles:6431:20
  </code></pre>