<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.development.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.development.js"></script>
<script type="text/babel">
const { useState } = React;
// State to store the image URL
const [imageUrl, setImageUrl] = useState('https://www.sarkarinaukriexams.com/images/bio/1695902312-bio.png');
// Function to handle user input or API response to change the image URL
const handleInputChange = (event) => {
setImageUrl(event.target.value);
<div className='container'>
<h3>React Js Display Image using useState</h3>
{/* Input field to allow users to enter the image URL */}
placeholder="Enter Image URL"
onChange={handleInputChange}
className="input-field" // Add a class name to the input field
{/* Display the image using the updated imageURL state */}
<img src={imageUrl} alt="Image Description" className="image-element" /> {/* Add a class name to the image */}
ReactDOM.render(<App />, document.getElementById('app'));
box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.2);
.input-field::placeholder {
/* Placeholder text color */
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
/* Box shadow for the image */
/* Optional: Add hover effect to the image */
/* Increase size on hover */
transition: transform 0.3s ease;