<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: GAGAN MISHRA</title>
    <description>The latest articles on DEV Community by GAGAN MISHRA (@1g2r3m).</description>
    <link>https://dev.to/1g2r3m</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1159242%2Fe5203936-b123-46af-94b9-47e1d10579e3.jpeg</url>
      <title>DEV Community: GAGAN MISHRA</title>
      <link>https://dev.to/1g2r3m</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/1g2r3m"/>
    <language>en</language>
    <item>
      <title>Can anyone please help me out: I'm not able to debug the code in Reacts JS</title>
      <dc:creator>GAGAN MISHRA</dc:creator>
      <pubDate>Wed, 13 Sep 2023 12:19:59 +0000</pubDate>
      <link>https://dev.to/1g2r3m/im-not-able-to-debug-the-code-in-reacts-js-56kh</link>
      <guid>https://dev.to/1g2r3m/im-not-able-to-debug-the-code-in-reacts-js-56kh</guid>
      <description>&lt;p&gt;I'm a aspiring frontend developer currently learning React JS while making mini projects. Currently working on React Calculator.&lt;br&gt;
When I included handleClick event browser console started showing error&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0FuzYISl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nlllegxbly8sui0uznos.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0FuzYISl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nlllegxbly8sui0uznos.jpg" alt="Image description" width="800" height="600"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--n5ahrjFE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oot4ayvinop9hefe64ax.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--n5ahrjFE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oot4ayvinop9hefe64ax.jpg" alt="Image description" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below is my code &lt;/p&gt;

&lt;p&gt;`import React, {Component} from "react";&lt;br&gt;
import CalculatorTitle from "./calculatorTitle.js";&lt;br&gt;
import OutputScreen from "./outputScreen.js";&lt;br&gt;
import Button from "./button.js";&lt;/p&gt;

&lt;p&gt;class Calculator extends Component {&lt;br&gt;
    constructor() {&lt;br&gt;
        super();&lt;br&gt;
        this.state = {&lt;br&gt;
            question: "",&lt;br&gt;
            answer: ""&lt;br&gt;
        };&lt;br&gt;
        this.handleClick = this.handleClick.bind(this);&lt;br&gt;
    }&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;handleClick(event) {
    const value = event.target.value;

    switch (value) {
        case "=": {
            if (this.state.question !== "") {
                var ans = "";
                try {
                    ans = eval(this.state.question);
                } catch (err) {
                    this.setState({ answer: "Math Error" });
                }
                if (ans === undefined) this.setState({ answer: "Math Error" });
                // update answer in our state.
                else this.setState({ answer: ans, question: "" });
                break;
            }

        }
        case "Clear": {
            this.setState({ question: "", answer: "" });
            break;
        }
        case "Delete": {
            const str = this.state.question;
            const newStr = str.slice(0, str.length - 1);
            this.setState({ question: newStr });
            break;
        }
        default: {
            this.setState(prevState =&amp;gt; ({
              question: prevState.question + value
            }));
            break;
          }

}


render() {
    return (
        &amp;lt;&amp;gt;
            &amp;lt;div className="frame"&amp;gt;
            &amp;lt;CalculatorTitle value="My Calculator" /&amp;gt;
            &amp;lt;div className="mainCalc"&amp;gt;
                &amp;lt;OutputScreen question={this.state.question} answer={this.state.answer} /&amp;gt;
                &amp;lt;div className="button-row"&amp;gt;
                    &amp;lt;Button label={"Clear"} handleClick={this.handleClick} /&amp;gt;
                    &amp;lt;Button label={"Delete"} handleClick={this.handleClick} /&amp;gt;
                    &amp;lt;Button label={"."} handleClick={this.handleClick} /&amp;gt;
                    &amp;lt;Button label={"/"} handleClick={this.handleClick} /&amp;gt;
                    &amp;lt;Button label={"7"} handleClick={this.handleClick} /&amp;gt;
                    &amp;lt;Button label={"8"} handleClick={this.handleClick} /&amp;gt;
                    &amp;lt;Button label={"9"} handleClick={this.handleClick} /&amp;gt;
                    &amp;lt;Button label={"*"} handleClick={this.handleClick} /&amp;gt;
                    &amp;lt;Button label={"4"} handleClick={this.handleClick} /&amp;gt;
                    &amp;lt;Button label={"5"} handleClick={this.handleClick} /&amp;gt;
                    &amp;lt;Button label={"6"} handleClick={this.handleClick} /&amp;gt;
                    &amp;lt;Button label={"-"} handleClick={this.handleClick} /&amp;gt;
                    &amp;lt;Button label={"1"} handleClick={this.handleClick} /&amp;gt;
                    &amp;lt;Button label={"2"} handleClick={this.handleClick} /&amp;gt;
                    &amp;lt;Button label={"3"} handleClick={this.handleClick} /&amp;gt;
                    &amp;lt;Button label={"+"} handleClick={this.handleClick} /&amp;gt;
                    &amp;lt;Button label={"0"} handleClick={this.handleClick} /&amp;gt;
                    &amp;lt;Button label={"="} handleClick={this.handleClick} /&amp;gt;
                &amp;lt;/div&amp;gt;


                &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;

        &amp;lt;/&amp;gt;
    );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;export default Calculator;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
