Created
February 1, 2021 18:20
-
-
Save sonicoder86/d8da57a357df79885933dd93c7bdc80b to your computer and use it in GitHub Desktop.
Write Vue like you write React - part 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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