0.0.3 • Published 6 years ago
periodic-data-refetcher v0.0.3
<PeriodicDataRefetcher />
Component that handles refetching data for a component periodically, with pause/resume functionality.
Properties
dataPath
dataParams
mockJson
secondsBetweenRefetch
childComponent
loadingComponent
emptyComponent
errorComponent
Data Props passed on your childComponent
/loadingComponent
/emptyComponent
/errorComponent
all response data
all error response data from axios
isPeriodicRefetchEnabled
togglePeriodicRefetch()
Usage
import React from "react";
import DetailWrapper from "./DetailWrapper";
import PeriodicDataRefetcher from "periodic-data-refetcher";
let mockJson = undefined;
if (process.env.NODE_ENV === "development") {
mockJson = require("../mockDetailsJson.json");
}
const DetailListWithData = props => (
<PeriodicDataRefetcher
dataPath="/getDetailsJson"
dataParams={{
groupId: props.groupId
}}
mockJson={mockJson}
secondsBetweenRefetch={60}
childComponent={dataProps => <DetailList {...dataProps} />}
/>
);
export default DetailListWithData;