# Passing event arguments: error

**URL:** <https://forum.codewithmosh.com/t/passing-event-arguments-error/15865>\
**Category:** React\
**Created:** [October 14, 2022, 11:05am UTC](https://forum.codewithmosh.com/t/passing-event-arguments-error/15865 "2022-10-14T11:05:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![danmanca1983](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/danmanca1983/32/4815_2.png) [@danmanca1983](https://forum.codewithmosh.com/u/danmanca1983)\
**Post date:** [October 14, 2022, 11:05am UTC](https://forum.codewithmosh.com/t/passing-event-arguments-error/15865/1 "2022-10-14T11:05:52Z")

</div>

Hi there,

I have purchased the React course by Mosh and am going through the materials, currently a little stuck on lesson 14, where he shows how to pass event arguments.

As per the video, I have the below code, within the render method:

```auto
render() { 

        return(
            <div>
                <span className={this.getBadgeClasses()}>{ this.formatCount() }</span>
                <button 
                    onClick={() => this.handleIncrement(product) } 
                    className='btn btn-secondary btn-sm'>Increment</button>
            </div>
        )
    }

```

And this is the handleIncrement method code I have:

```auto
handleIncrement = product => {
        console.log(product);
        this.setState({ count: this.state.count + 1 })
};

```

Product however, is detected as undefined…

If anyone could help would be great.

---

<div class="post-metadata">

**Author:** ![onlyhasbi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/onlyhasbi/32/4608_2.png) [@onlyhasbi](https://forum.codewithmosh.com/u/onlyhasbi)\
**Post date:** [October 15, 2022, 1:16am UTC](https://forum.codewithmosh.com/t/passing-event-arguments-error/15865/2 "2022-10-15T01:16:27Z")

</div>

The product becomes undefined because you didn’t assign any value.  
made little change to your code

`<button onClick={() => this.handleIncrement('Some Food') } className='btn btn-secondary btn-sm'> Increment </button>`

---

<div class="post-metadata">

**Author:** ![AzharUddinSheikh](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/azharuddinsheikh/32/5561_2.png) [@AzharUddinSheikh](https://forum.codewithmosh.com/u/AzharUddinSheikh)\
**Post date:** [October 18, 2022, 6:34am UTC](https://forum.codewithmosh.com/t/passing-event-arguments-error/15865/3 "2022-10-18T06:34:19Z")

</div>

> [@danmanca1983](#):
>
> `onClick={() => this.handleIncrement(product)`

what is `product`?

**You forgot to define product**

---

<div class="post-metadata">

**Author:** ![danmanca1983](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/danmanca1983/32/4815_2.png) [@danmanca1983](https://forum.codewithmosh.com/u/danmanca1983)\
**Post date:** [October 18, 2022, 7:01am UTC](https://forum.codewithmosh.com/t/passing-event-arguments-error/15865/4 "2022-10-18T07:01:50Z")

</div>

Thanks for the response, product is the parameter Mosh passes on the handleIncrement() method on the video, as he writes the code, I know it is not defined, but on his clip it does not have such problem. I am a little confused as to why to be honest.

---

<div class="post-metadata">

**Author:** ![TinMan](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@TinMan](https://forum.codewithmosh.com/u/TinMan)\
**Post date:** [October 18, 2022, 2:54pm UTC](https://forum.codewithmosh.com/t/passing-event-arguments-error/15865/5 "2022-10-18T14:54:44Z")

</div>

Linters evolve over time; it is possible that linting rules have changed since he made his video.

You are currently trying to call a method with a variable that does not exist.

You can simply just create a product variable in the class and set it to null for now to bypass the error.

i.e. `const product = null`

or just pass null as an argument

`onClick={() => this.handleIncrement(null) }`

---

<div class="post-metadata">

**Author:** ![danmanca1983](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/danmanca1983/32/4815_2.png) [@danmanca1983](https://forum.codewithmosh.com/u/danmanca1983)\
**Post date:** [October 20, 2022, 9:48am UTC](https://forum.codewithmosh.com/t/passing-event-arguments-error/15865/6 "2022-10-20T09:48:57Z")

</div>

Thanks for the response 🙂

---

<div class="post-metadata">

**Author:** ![AzharUddinSheikh](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/azharuddinsheikh/32/5561_2.png) [@AzharUddinSheikh](https://forum.codewithmosh.com/u/AzharUddinSheikh)\
**Post date:** [November 20, 2022, 8:24am UTC](https://forum.codewithmosh.com/t/passing-event-arguments-error/15865/7 "2022-11-20T08:24:50Z")

</div>

> [@danmanca1983](#):
>
> but on his clip it does not have such problem. I am a little confused as to why to be honest.

it’s just an example, that you can pass `id` or `item` like this  
it’s long time when I watched this course may be he did define `product` but unable to record that part or might be he didn’t click on that button

anyways You have to define the `product`
