Tuesday, May 14, 2024
 Popular · Latest · Hot · Upcoming
197
rated 0 times [  200] [ 3]  / answers: 1 / hits: 10106  / 2 Years ago, thu, november 17, 2022, 12:00:00

NextJS Error Message


Error: Event handlers cannot be passed to Client Component props.

^^^^^^^^^^
If you need interactivity, consider converting part of this to a Client Component.


const reqHelp = () => {
Swal.fire({
title: '1',
text: '1',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes',
cancelButtonText: 'No',
})
}

return(
<div className="buttons">
<button onClick={reqHelp} className="stopwatchButton">Request Help</button>
</div>
);

Search NextJS 13 Official Document and about Server/Client Render


More From » reactjs

 Answers
5

Add 'use client' on top of the file where you are using handleClick because all components in Next 13 by default are server components, therefore for client side interactivity you need to use "use client".


[#13] Thursday, August 11, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bradford

Total Points: 709
Total Questions: 117
Total Answers: 91

Location: Sao Tome and Principe
Member since Wed, Dec 21, 2022
1 Year ago
bradford questions
;