Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
When displaying an image, which of the following two measures should be taken with React

I wrote the following code in React.

 const onChangeImage = (e, setState) => {
        const file = e.target.files[0]
        if (e.target.files && e.target.files[0]) {
            // 画像を格納
            reader.onload = (data) => {
                dispatch({
                    type: 'SET_SALON_DATA',
                    payload: {
                        title: e.target.name,
                        content: file
                    }
                })
                // this!!
            }
            reader.readAsDataURL(file)
        }
    }

At "this!!" point,which method is better? This state goes into the url of the img tag.

setState(URL.createObjectURL(file))

or

setState(data.target.result))

I'm waiting for your answer!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!