Last active
June 11, 2021 20:36
-
-
Save ignatius22/c87f5edfe172f8228ac008bf754d0ed8 to your computer and use it in GitHub Desktop.
Result of converted component from class in to a funcrional component.
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, { useEffect } from "react"; | |
const MyComponent = ({ fetchDrafts, fetchHistory }) => { | |
useEffect(() => { | |
fetchDrafts(); | |
fetchHistory(); | |
const fetchDraftsTimer = setInterval(() => { | |
fetchDrafts(); | |
}, 120000); | |
return () => { | |
clearInterval(fetchDraftsTimer); | |
}; | |
}, [fetchDrafts, fetchHistory]); | |
return null; | |
}; | |
export default MyComponent; |
done with the changes, please review. Thanks.
Hello, I've made the changes, could you please review it?
thank you.
…On Wed, Jun 9, 2021 at 8:21 PM Andrew Schenk ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
I'm sorry, this answer is incorrect. Don't worry, we don't get everything
right on the first try either.
This is an open book question.
- Use a Javascript IDE
- Try running the code
- Check documentation
- Format and tidy final product
Please take some time and resubmit.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://gist.github.com/c87f5edfe172f8228ac008bf754d0ed8#gistcomment-3774553>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMGTPOXRZGZMGJNTDIEQBQ3TR65MVANCNFSM46MVI7VA>
.
You are close.
- The original class component was missing critical logic that is also absent from here
- Double check your props and dependency arrays. They look odd
- Proper formatting will make it more readable
critical logic will be to clear the interval after setting it.
"fetchDraftsTimer" shouldn't be passed as a dependency or props.
I think everything looks okay now. Please kindly review.
Thanks.
Thank you for the feedback!
…On Thu, Jun 10, 2021 at 7:37 PM Andrew Schenk ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
You are close.
- The original class component was missing critical logic that is also
absent from here
- Double check your props and dependency arrays. They look *odd*
- Proper formatting will make it more readable
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://gist.github.com/c87f5edfe172f8228ac008bf754d0ed8#gistcomment-3775970>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMGTPOQE5IZVSWC73P4J6MTTSEA6FANCNFSM46MVI7VA>
.
That's right.
Thank you!
…On Fri, Jun 11, 2021, 6:10 PM Andrew Schenk ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
That's right.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://gist.github.com/c87f5edfe172f8228ac008bf754d0ed8#gistcomment-3777230>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMGTPOXXY3UZQRECI7X25Z3TSI7PDANCNFSM46MVI7VA>
.
I got rejected, anyway. But thanks for the time you put into reviewing the
code.
…On Fri, Jun 11, 2021 at 9:15 PM Ignatius Sani ***@***.***> wrote:
Thank you!
On Fri, Jun 11, 2021, 6:10 PM Andrew Schenk ***@***.***>
wrote:
> ***@***.**** commented on this gist.
> ------------------------------
>
> That's right.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://gist.github.com/c87f5edfe172f8228ac008bf754d0ed8#gistcomment-3777230>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AMGTPOXXY3UZQRECI7X25Z3TSI7PDANCNFSM46MVI7VA>
> .
>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm sorry, this answer is incorrect. Don't worry, we don't get everything right on the first try either.
This is an open book question.
Please take some time and resubmit.