-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,40 @@ | ||
import axios from 'axios'; | ||
import React, { useState, useEffect } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import axios from "axios"; | ||
import React, { useState, useEffect } from "react"; | ||
import { useSelector } from "react-redux"; | ||
|
||
function DiaryImage({ wantEdit, imgURL, setImgFile, preview, setPreview }) { | ||
const selectPicture = (e) => { | ||
setPreview(() => window.URL.createObjectURL(e.target.files[0])); | ||
setImgFile(() => e.target.files[0]); | ||
}; | ||
return ( | ||
<> | ||
{wantEdit ? <input type="file" id="file" accept="image/*" onChange={selectPicture} /> : null} | ||
<div className="diary-image"> | ||
{wantEdit ? ( | ||
<input | ||
type="file" | ||
id="file" | ||
accept="image/*" | ||
onChange={selectPicture} | ||
/> | ||
) : null} | ||
<div className="diary-box__img-file-wrapper"> | ||
{!preview && !imgURL ? ( | ||
<div> | ||
<img src={'images/photoCat.png'} alt="defaultImg" /> | ||
<p>사진을 남겨주세요</p> | ||
<img src={"images/photoCat.png"} alt="defaultImg" /> | ||
<div className="diary-image__text"> | ||
오늘 하루를 기록할 수 있는 사진을 남겨주세요 | ||
</div> | ||
</div> | ||
) : null} | ||
{!preview && imgURL ? ( | ||
<img src={process.env.REACT_APP_SERVER_URL + `/images/${imgURL}`} alt="diaryImg" /> | ||
<img | ||
src={process.env.REACT_APP_SERVER_URL + `/images/${imgURL}`} | ||
alt="diaryImg" | ||
/> | ||
) : null} | ||
{preview ? <img src={preview} alt="preview" /> : null} | ||
</div> | ||
</> | ||
</div> | ||
); | ||
} | ||
export default React.memo(DiaryImage); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.