React is a JavaScript library developed by Facebook for building fast and interactive user interfaces. It's based on reusable components and a declarative approach, making it easier to manage dynamic content.
import React, { useState } from 'react';
const Counter = () => {
const [count, setCount] = useState(0);
const increment = () => setCount(count + 1);
return (
Counter: {count}
);
};
export default Counter;
This is a simple Counter
component that uses React’s useState
hook to manage its internal state. Every time the button is clicked, the state (count
) increments, and the component re-renders.