Skip to content

Instantly share code, notes, and snippets.

@cecigarcia
Last active September 27, 2019 10:50
Show Gist options
  • Save cecigarcia/8726e4319e9e1bebbbe86135aefab7ff to your computer and use it in GitHub Desktop.
Save cecigarcia/8726e4319e9e1bebbbe86135aefab7ff to your computer and use it in GitHub Desktop.
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