ImageList.js
import React, { useContext } from 'react';
import { ImageContext } from '../context/ImageContext';
const ImageList = () => {
const { images, myImages, isPublic, setIsPublic } = useContext(ImageContext);
console.log(myImages);
const imgList = (isPublic ? images : myImages).map((image) => (
<img
alt=""
key={image.key}
style={{ width: '100%' }}
src={`http://localhost:8000/uploads/${image.key}`}
/>
));
return (
<div>
<h3 style={{ display: 'inline-block', marginRight: 10 }}>
Image List({isPublic ? '공개' : '개인'} 사진)
</h3>
<button onClick={() => setIsPublic(!isPublic)}>
{(isPublic ? '개인' : '공개') + ' 사진 보기'}
</button>
{imgList}
</div>
);
};
export default ImageList;
error: (intermediate value).map is not a function
ImageContext.js >
const [myImages, setMyImages] = useState([]);
myImages 가 문제인거 같은데..함수가 아니라니..원인을 알 수가 없네요 ~ㅠㅠ