I'm new to Typescript and I'm having a hard time trying to understand why my code isn't working.
I'm trying to build a carousel image gallery using react and typescript and i'm having problems when I try to use "onClick" on the left and right arrows for navigation.
I get the following errors:
Type
'{ onClick: () => void; }'is not assignable to type'IntrinsicAttributes'. Property'onClick'does not exist on type'IntrinsicAttributes'.
Here's my code:
const Carousel = ({ slides }) => {
return (
<section className="slider">
<ArrowRight onClick = {nextSlide} /> //The error is here!
<ArrowLeft onClick = { () => prevSlide() } /> //and here!
{slides.map((slide, index) => {
return (
<div className="img-slide">
<img src={slide.image} />
<div className="rolo-slide">
{/* <img src={slide.image} onClick={slides.setCurrent(index)} /> */}
</div>
</div>
)
})}
</section>
)
}
export default Carousel
Here's what ArrowLeft and Right are, they're just a span, I made the arrows using CSS.
function ArrowLeft() {
return (
<span className="arrow left"></span>
)
}

IntrinsicAttributes?ArrowRightandArrowLeft. Ideally, reduce the problem to a minimal reproducible example and post just that code, without extraneous other parts, to the question (and preferably also a link to that same code in the TypeScript playground). That makes it much easier for us to help you.ArrowRightcomponent doesn't haveonClickin its props typing definition.