Skip to content

Commit

Permalink
try to delay ready state
Browse files Browse the repository at this point in the history
  • Loading branch information
fachrihawari committed Oct 2, 2024
1 parent 206506d commit 7cc7c80
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/(main)/payment/[token]/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export default function Error(props: { error: Error }) {
console.log(props.error.message)
console.log(props.error.stack)

return 'Ooppps'
return null
}
6 changes: 5 additions & 1 deletion src/lib/hooks/useMidtrans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export function useMidtrans({ onSuccess, onPending, onError, onClose }: Midtrans
script.src = 'https://app.sandbox.midtrans.com/snap/snap.js'
script.setAttribute('data-client-key', process.env.NEXT_PUBLIC_MIDTRANS_CLIENT_KEY)

script.onload = () => setIsReady(true)
script.onload = () => {
setTimeout(() => {
setIsReady(true)
}, 500); // make sure the script evaluation finished
}
document.body.appendChild(script)
return () => {
document.body.removeChild(script)
Expand Down

0 comments on commit 7cc7c80

Please sign in to comment.