Skip to content

Instantly share code, notes, and snippets.

@ignatius22
Last active June 11, 2021 20:36
Show Gist options
  • Save ignatius22/c87f5edfe172f8228ac008bf754d0ed8 to your computer and use it in GitHub Desktop.
Save ignatius22/c87f5edfe172f8228ac008bf754d0ed8 to your computer and use it in GitHub Desktop.
Result of converted component from class in to a funcrional component.
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;
@ignatius22
Copy link
Author

ignatius22 commented Jun 11, 2021 via email

@ignatius22
Copy link
Author

ignatius22 commented Jun 11, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment