Last active
May 20, 2022 03:15
-
-
Save cyberfly/25436753c31da19aec267a7997176e80 to your computer and use it in GitHub Desktop.
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 React, { useState, useEffect } from "react"; | |
| import GenerateCounter from "../components/GenerateCounter"; | |
| import { generateArticle } from "../services/ArticleService"; | |
| const Generate = () => { | |
| const [count, setCount] = useState(1); | |
| const updateCount = new_count => { | |
| setCount(new_count); | |
| }; | |
| return ( | |
| <> | |
| <div className="my-10"> | |
| <GenerateCounter count={count} updateCount={updateCount}></GenerateCounter> | |
| </div> | |
| </> | |
| ); | |
| }; | |
| export default Generate; |
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 React, { useState, useEffect } from "react"; | |
| const GenerateCounter = ({ count, updateCount, ...restProps }) => { | |
| const handleClick = (e) => { | |
| let new_count = count + 1; | |
| updateCount(new_count); | |
| }; | |
| return ( | |
| <> | |
| <button | |
| onClick={(e) => handleCounterClick(e)} | |
| type="button" | |
| className="text-3xl border p-4" | |
| > | |
| Plus | |
| </button> | |
| </> | |
| ); | |
| }; | |
| export default GenerateCounter; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment