For some reason, NO ‘use client’ pages can get the “onClick” to work at all. The button clicks, does nothing. Tried adding a console.log(‘clicked’). Nothing. Tried changing it to a click handler, same, nothing. Any ideas? Otherwise I have to skip dynamic routing because it isn’t working @moshhamedani
'use client';
import {useRouter} from 'next/navigation'
import React from 'react';
const NewUserPage = () => {
const router = useRouter();
return (
<button className="btn btn-primary" onClick={ () =>{
console.log('working');
router.push('/users');
}}>
Create User
</button>
);
};
export default NewUserPage;
Not even the homepage. Is this course seriously out of date?
'use client'
import React from 'react'
const AddToCart = () => {
return (
<button className='btn btn-primary' onClick={()=> console.log('Click')}>Add to cart</button>
)
}
export default AddToCart