Last active
September 27, 2019 10:50
-
-
Save cecigarcia/8726e4319e9e1bebbbe86135aefab7ff to your computer and use it in GitHub Desktop.
This file contains 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 React, { useState, useEffect } from "react"; | |
const Component = ({ notifyEven }) => { | |
const [value, setValue] = useState(0); | |
useEffect(() => { | |
if ((value % 2) === 0) { | |
notifyEven(value); | |
} | |
}, [value]); | |
return ( | |
<button onClick={() => setValue(value + 1)}>Increment</button> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment