import React, { useState } from 'react';
function Counter() {
const [value, setValue] = useState(0);
return (
<>
<p> Counter: {value} </p>
<button type="button" onClick={() => setValue(value + 1)}>
Increment
</button>
<button type="button" onClick={() => setValue(value - 1)}>
Decrement
</button>
</>
)
}
export default Counter;
import { h } from 'preact';
import { useState } from 'preact/hooks';
function Counter() {
const [value, setValue] = useState(0);
return (
<>
<p> Counter: {value} </p>
<button type="button" onClick={() => setValue(value + 1)}>
Increment
</button>
<button type="button" onClick={() => setValue(value - 1)}>
Decrement
</button>
</>
)
}
export default Counter;