Skip to content

Instantly share code, notes, and snippets.

@sonicoder86
Created February 1, 2021 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sonicoder86/d8da57a357df79885933dd93c7bdc80b to your computer and use it in GitHub Desktop.
Save sonicoder86/d8da57a357df79885933dd93c7bdc80b to your computer and use it in GitHub Desktop.
Write Vue like you write React - part 1
import { useState, useEffect } from 'react';
export const Counter = ({ limit, onLimit }) => {
const [count, setCount] = useState(0);
const handler = () => setCount(count + 1);
useEffect(
() => (count >= limit) ? onLimit() : null,
[count]
);
return <button type="button" onClick={handler}>
Count: {count}
</button>;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment