Reputation: 27
I want to get the value of my icon but it says that event is deprecated.
const TaskContainer = (props) => {
function handleChange(event){
alert(event.target.value);
}
return (
<i className='bx bx-add-to-queue bx-tada-hover' value={props.columnname.id} onClick={handleChange(event)} ></i>
)
}
Upvotes: 0
Views: 43
Reputation: 46
I believe you need to write like this:
onClick={event => handleChange(event)}
Or that way:
onClick={handleChange}
Upvotes: 3
Reputation: 783
You're calling the function, instead you should do this-
<i className='bx bx-add-to-queue bx-tada-hover' value={props.columnname.id} onClick={handleChange} ></i>
or,
<i className='bx bx-add-to-queue bx-tada-hover' value={props.columnname.id} onClick={(event) => handleChange(event)} ></i>
Please have a look at handling events in react for better understanding of how event handlers should be put up in react.
Upvotes: 0