Skip to content

Instantly share code, notes, and snippets.

@ibare
Created June 4, 2019 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibare/0853f885a29b1db959cf9a8ff38e089c to your computer and use it in GitHub Desktop.
Save ibare/0853f885a29b1db959cf9a8ff38e089c to your computer and use it in GitHub Desktop.
비동기 작업 요청 상태
const OrderList: React.FC<IProps> = props => {
const [request, completeRequest] = React.useState(false);
const [requestId, upddateRequestId] = React.useState(0);
if (request && checkCompleteTask(props.asyncTasks, requestId)) {
completeRequest(false);
}
React.useEffect(() => {
const {
payload: { id }
} = props.createAsyncTask();
completeRequest(true);
upddateRequestId(id);
setTimeout(() => {
props.completeAsyncTask(id);
}, 1000);
}, []);
return <OrderListComponent loading={request} {...props} />;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment