Junior — Middle
Can you implement a component based on React?
sobes.tech AI
Answer from AI
Yes, I can implement a React component. Here's a simple example of a functional component that displays a button and counts the number of clicks:
import React, { useState } from 'react';
function ClickCounter() {
const [count, setCount] = useState(0);
return (
<div>
<p>You clicked the button {count} times</p>
<button onClick={() => setCount(count + 1)}>Click me</button>
</div>
);
}
export default ClickCounter;
This component uses the useState hook to store the counter state and updates it on each button click.