Created
April 22, 2024 18:58
-
-
Save lovemycodesnippets/a1ec308571bf3ef615d91d3378773a67 to your computer and use it in GitHub Desktop.
AbortController API in React_1
This file contains 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
import { useState } from 'react'; | |
function App() { | |
const [pictureUrl, setPictureUrl] = useState(''); | |
return ( | |
<div | |
style={{ | |
display: 'flex', | |
alignItems: 'center', | |
gap: '2rem', | |
flexDirection: 'column', | |
marginTop: '2rem', | |
}} | |
> | |
<div style={{ display: 'flex', gap: '2rem' }}> | |
<button>Get Random Picture</button> | |
<button> Cancel Request</button> | |
</div> | |
<div> | |
{pictureUrl !== '' ? <img src={pictureUrl} alt='random user' /> : null} | |
</div> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment