react functional component with state code example
Example 1: react functional components
const component = () => {
console.log("This is a functional Component");
}
Example 2: functional component react with state
import React, { useState } from 'react';
function Example() {
// Declare a new state variable, which we'll call "count" const [count, setCount] = useState(0);
return (
<div>
<p>You clicked {count} times</p>
<button onClick={() => setCount(count + 1)}>
Click me
</button>
</div>
);
}