react - simple hello world component
To create a simple hello world react component, i used the following to create my component.
import { useState } from 'react';
type ButtonProps = {
children: React.ReactNode;
};
export const MyCounter = (props: ButtonProps) => {
const [count, setCount] = useState(0);
return (
<>
<button onClick={() => setCount((count) => count + 1)}>
mycount is {count}
</button>{' '}
</>
);
};
Then i wired it up using
import { MyCounter } from './mycounter';
function App() {
return (
<>
<MyCounter />
</>
);
}
Example code:
https://stackblitz.com/edit/vitejs-vite-fx2pxk
Comments