Open
Conversation
joi0104
commented
Feb 19, 2021
| getNextPostId, | ||
| } from 'firebase/database/Post'; | ||
|
|
||
| const PostContext = createContext<any>(null); |
Member
Author
There was a problem hiding this comment.
이 부분.. 타입에러 해결을 어떻게 해야할지 모르겠더라구요.. any를 해소할 수 있는 방법이 있을까요?
Collaborator
There was a problem hiding this comment.
interface PostsType {
posts: PostInterface[];
}
interface ActionsType {
createPost: (
writer: string,
writerImgUrl: string,
content: string,
) => Promise<void>;
fetchPosts: () => Promise<void>;
}
interface PostContextType {
state: PostsType;
actions: ActionsType;
}
const PostContext = createContext<PostContextType | null>(null);예시코드로 작성한거라 네이밍 맘대로 했지만 저렇게 PostContext에 들어갈 value에 대한 타입을 지정해주면 될것 같아요
danivelop
reviewed
Feb 19, 2021
| const Main = () => { | ||
| const [nextSlide, setNextSlide] = useState(0); | ||
| const { state, actions } = usePostContext(); | ||
| const reversePosts = [...state.posts].reverse(); |
Collaborator
There was a problem hiding this comment.
Suggested change
| const reversePosts = [...state.posts].reverse(); | |
| const reversePosts = useMemo(() => state.posts.reverse(), [state.posts]) |
reverse함수는 리렌더링시마다 배열을 도는 비용이 들어 메모이제이션 해주면 조금이나마 성능상 이점이 있을꺼같아요!
There was a problem hiding this comment.
reverse가 원본 배열을 뒤집는 이슈가 있어서
useMemo(() => {
const newPosts = [...state.posts];
newPosts.reverse();
return newPosts;
}, [state.posts]);
가 되어야 할 거 같아요
Member
Author
There was a problem hiding this comment.
오오! 안그래도 이부분 코드가 마음에 걸렸는데.. 감사합니다!
Comment on lines
+3
to
+12
| const firebaseConfig = { | ||
| apiKey: 'AIzaSyBEHGPNsfIAkQFgkOGoIF5WmnzYFPMql1s', | ||
| authDomain: 'test-62120.firebaseapp.com', | ||
| databaseURL: 'https://test-62120-default-rtdb.firebaseio.com', | ||
| projectId: 'test-62120', | ||
| storageBucket: 'test-62120.appspot.com', | ||
| messagingSenderId: '430861282500', | ||
| appId: '1:430861282500:web:06548314dd0d847809ad91', | ||
| measurementId: 'G-FGSXX73220', | ||
| }; |
kand193
reviewed
Feb 20, 2021
| [https://github.com/dl0312/open-apis-korea](https://github.com/dl0312/open-apis-korea) - 다양한 카테고리가 장점! 한국인이 작성한 문서라 문서가 한국어라 사용하기 편리함 | ||
| [https://english.api.rakuten.net](https://english.api.rakuten.net) - API계의 큰손 라쿠텐 api. 유용한 API들을 판매하는 마켓플레이스로 유용한 api들이 많고 유료인만큼 사용법이나 예시코드가 잘되있음. 일정 사용량부터 과금되서 토이프로젝트용으로는 무료로 사용할 수 있는 api 많음 No newline at end of file | ||
|
|
||
| [https://avatars.dicebear.com](https://avatars.dicebear.com) - 유저 아바타를 유저 이름을 기반으로 랜덤하게 생성해주는 open api. |
| align-items: center; | ||
| overflow: auto; | ||
| border: none; | ||
| margin-right: 20px; |
There was a problem hiding this comment.
css의 프로퍼티 순서가 연관있는 것끼리 묶여서 일관되게 보이면 좋을거같아요!
Member
Author
There was a problem hiding this comment.
아아 넵! Scss의 믹스인으로 묶는것도 좋을 것 같네여 ㅎㅎ
Comment on lines
+3
to
+12
| const firebaseConfig = { | ||
| apiKey: 'AIzaSyBEHGPNsfIAkQFgkOGoIF5WmnzYFPMql1s', | ||
| authDomain: 'test-62120.firebaseapp.com', | ||
| databaseURL: 'https://test-62120-default-rtdb.firebaseio.com', | ||
| projectId: 'test-62120', | ||
| storageBucket: 'test-62120.appspot.com', | ||
| messagingSenderId: '430861282500', | ||
| appId: '1:430861282500:web:06548314dd0d847809ad91', | ||
| measurementId: 'G-FGSXX73220', | ||
| }; |
| <option value="bottts">bottts</option> | ||
| <option value="avataaars">avataaars</option> | ||
| <option value="jdenticon">jdenticon</option> | ||
| <option value="gridy">gridy</option> |
| const Main = () => { | ||
| const [nextSlide, setNextSlide] = useState(0); | ||
| const { state, actions } = usePostContext(); | ||
| const reversePosts = [...state.posts].reverse(); |
There was a problem hiding this comment.
reverse가 원본 배열을 뒤집는 이슈가 있어서
useMemo(() => {
const newPosts = [...state.posts];
newPosts.reverse();
return newPosts;
}, [state.posts]);
가 되어야 할 거 같아요
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.
하고싶은 말을 포스팅하면 5분있다 사라지는 하고싶은 말 다하는 서비스!
저희팀은 닉네임을 받으면 랜덤으로 아바타를 생성해주는 API 를 이용해서
익명 로그인을 한 후 하고싶은 말을 포스팅하고 5분뒤에 사라지는 서비스를 개발했습니다!
실행
프로젝트 설치
$ git clone https://github.com/mash-up-kr-web/openapi-study.git
$ cd openapi-study
$ git checkout -b junghoo
$ git pull origin junghoo
실행
$ npm install
$ npm run start
http://localhost:3000에서 실행됩니다.