Created
June 4, 2019 08:46
-
-
Save ibare/0853f885a29b1db959cf9a8ff38e089c 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
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