title: Find function in React.JS
body: <p>I am receiving a props data is look like</p>
  
  <pre><code> data: [
      {
          rowNumber: 1,
          specification: null,
          validationMessage: [
              {
                  isExists: true,
                  errors: [
                      {
                          errorCode: "PredicateValidator",
                          errorMessage: "ERR: Length value is not in correct  "
                      },
                      {
                          errorCode: "PredicateValidator",
                          errorMessage: "Height Unit is not in correct  "
                      },
                  ]
              }
          ]
      },
      {
          rowNumber: 2,
          specification: null,
          validationMessage: [
              {
                  isExists: false,
                  errors: []
              }
          ]
      },
  ]
  </code></pre>
  
  <p>In my render I have a button and I am trying to disable/ enable that button based on my errorMessage. If my eoorMessage contains a word "ERR:" I will disable the button otherwise it will be enabled.
  Note: My errorMessage may be empty or may or may not have the word "Err:" word. If "ERR:" word exist any of my errorMessage I have to disable the button</p>
  
  <p>I have tried this but it says x is not defined. How can I overcome this?</p>
  
  <pre><code>render() {
  
   const hasError = this.props.data ? this.props.data.find((x) =&gt; x.validationMessage.erros.find(z =&gt; z.errorMessage.indexof("ERR:"))) : ''
      return (
      &lt;div&gt;
          {(this.props.data) ?
              &lt;div&gt;
  
                  (hasError) ?
                  &lt;Button variant="contained" className={classes.button} onClick={this.handleSave}&gt;Continue&lt;/Button&gt;
                  :
                  &lt;Button variant="contained" disabled={true} className={classes.button} onClick={this.handleSave}&gt;Continue&lt;/Button&gt;
  
  &lt;Button variant="contained" className={classes.button} onClick={this.handleCancle}&gt; Cancel&lt;/Button&gt;
                  &lt;/div&gt;
                  : ''}
          &lt;/div&gt;
      );
  </code></pre>