0

when I browse an image, I want to show this in web page using Hooks in react js ? like this.... sample output

1 Answer 1

1

Here is an example with hooks

import { useState } from "react";

export default function App() {
  const [file, setFile] = useState(null);

  const handleChange = (event) => {
    setFile(URL.createObjectURL(event.target.files[0]))
  }

  return (
    <>
      <input type="file" onChange={handleChange}/>
      <img src={file} />
    </>
  );
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.