Open
Conversation
Contributor
DeveloperRyou
left a comment
There was a problem hiding this comment.
4주차 과제도 잘 진행해주셨고, 캐러셀 부분 작업중이시다면 pr 주시면 피드백 드리겠습니다!
Comment on lines
+10
to
+22
| const [posts, setPosts] = useState<NoticeCardInterface[]>([]); | ||
| useEffect(() => { | ||
| axios | ||
| .get("https://jsonplaceholder.typicode.com/posts") | ||
| .then((response) => { | ||
| setPosts(response.data); | ||
| console.log("success!", response.data); | ||
| }) | ||
| .catch((error) => { | ||
| console.log("some errors", error); | ||
| }); | ||
| }, []); | ||
|
|
Contributor
There was a problem hiding this comment.
const [posts, setPosts] = useState<NoticeCardInterface[]>([]);
useEffect(() => {
async function getData() {
try {
const response = await axios.get("https://jsonplaceholder.typicode.com/posts");
setPosts(response.data);
console.log("success!", response.data);
}
catch(error) {
console.log("some errors", error);
});
}
getData();
}, []);
이런식으로 진행할 수 있을 것 같습니다!
Contributor
There was a problem hiding this comment.
아 이런식으로 진행하면 나중에 좋은점이, getData같은 함수를 따로 빼서 관리할 수 있게 됩니다! axios 요청하는 함수를 따로 파일로 관리할 수 있게 되어 유지보수가 수월해 지겠죠
Contributor
Author
There was a problem hiding this comment.
캐러셀은 알려주신 slick라이브러리 사용해서 잘 마무리 했습니다!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.