Skip to content

Conversation

@chaerin-dev
Copy link
Member

  • 상태관리 없이 구현하는 것이 더 어려워서 Recoil을 이용한 전역상태관리까지 같이 구현하게 되었습니다.
  • React 공부를 따로 할 시간이 없어 지난 미팅 때 @codeisneverodd 님께서 설명해주신 내용과 구글링만을 바탕으로 구현하다보니 부족한 점이 많습니다. 리뷰 부탁드립니다.
  • CSS의 경우 Styled Component로 다시 구현하신다고 하셔서 아예 import 하지 않았습니다.
  • @yongchanson CSS 적용하실 때 로딩컴포넌트 position을 absolute로 해서 나머지 컴포넌트들을 덮도록 해주시면 될 것 같습니다.

@chaerin-dev chaerin-dev added the 프로젝트 TODO Projects 의 해야할 항목을 완료했을 때 사용합니다. label Jun 10, 2022
@chaerin-dev chaerin-dev self-assigned this Jun 10, 2022
@yongchanson yongchanson merged commit 183be94 into react-migration Jun 11, 2022
@yongchanson yongchanson deleted the caherin-react branch June 11, 2022 08:50
Copy link
Member

@codeisneverodd codeisneverodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋은 코드 잘 보았습니다! 고생 많이셨을 것 같네요 👍
리뷰 남겼으니 답글을 남기셔도 좋고, 반영을하셔도 좋을 것 같습니다!!

Comment on lines +6 to +23
export const solutionState = atom({
key: "solutionState",
default: {
level: 1,
fileName: "",
solution: [],
},
});

const root = ReactDOM.createRoot(document.getElementById('root'));
export const solutionNoState = atom({
key: "solutionNoState",
default: 0,
});

export const loadingState = atom({
key: "loadingState",
default: true,
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

atom.js 라는 파일을 새롭게 만들어 관리하면 좋을 것 같네요!

).join('')}
`;
export default function SearchableList() {
let [fileListHTML, changeState] = useState("");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

상태는 직접 변동이 불가능하고 set함수로만 변경할 수 있기 때문에 const로 선언하는 것이 좋아보입니다! 그리고 state가 여러개가되면 이름의 혼동이 있을 수 있기 때문에 다음과 같이 수정하는 것이 좋아보입니다.

const [fileListHTML, setFileListHTML] = useState("")

const setLoadingState = useSetRecoilState(loadingState);

// TODO: ``부분 수정 필요..
(async function fillList() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fillList에 대한 로직이 개선되어야할 것으로 보입니다! 우선 기존 로직을 이용해서 잘 구현해주셨다고 생각합니다. 하지만 상태 값이 생겼기 때문에 이제는 직접 돔을 채워주는 것이 아닌, 상태값을 이용한 형태로 구현이 가능할 것 같습니다.
예시를 적어보자면 아래와 같습니다.

  const POSSIBLE_LEVELS = [1, 2, 3, 4, 5];
  const [fileList, setFileList] = useState({})

  useEffect(()=>{
  const newFileList = Object.assign({},fileList)
  for (const level of POSSIBLE_LEVELS) {
        newFileList[level] = await getFileList(level);
  }
  setFileList(newFileList)
  },[ ])

 // 돔 내부
 {Object.entries(fileList).map(([level, files])=>{
  //로직 작성
})}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub을 통해 작성한 것이라 오류가 있을 수 있습니다! 참고용으로만 보아주세요 ㅎㅎ

@chaerin-dev
Copy link
Member Author

@codeisneverodd 👍👍👍 리뷰 남겨주신 부분 반영해보도록 하겠습니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

프로젝트 TODO Projects 의 해야할 항목을 완료했을 때 사용합니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants