Skip to content

[Discussion] issue on JSX에서 && 대신에 3항 연산자를 더 선호하는 이유 #527

@iicdii

Description

@iicdii

https://yceffort.kr/2020/10/use-ternaries-not-and-and-in-jsx

안녕하세요, 최근에 yceffort님 블로그를 알게 되서 재미있게 보고 있는 독자입니다 ㅎㅎ
먼저 글을 보다가 이미지가 엑박 뜨는 문제가 있어서 제보합니다.


screenshot


그리고, 본문에서 제시하신 방법(students.length === 0 &&)도 좋지만 !students.length &&와 같이 표현하면 더 짧게 줄일 수 있어서 좋은거 같습니다.
그리고 이번에 React 18이 업데이트 되면서 undefined 리턴이 허용되면서 에러에 대한 걱정이 하나 줄어들었습니다. 이 부분에 대한 언급도 있으면 좋지 않을까 싶습니다 ㅎㅎ

Components can now render undefined: React no longer warns if you return undefined from a component. This makes the allowed component return values consistent with values that are allowed in the middle of a component tree. We suggest to use a linter to prevent mistakes like forgetting a return statement before JSX.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions