Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve conditionals to avoid code littering #105

Open
gomorizsolt opened this issue Apr 8, 2020 · 2 comments
Open

Improve conditionals to avoid code littering #105

gomorizsolt opened this issue Apr 8, 2020 · 2 comments

Comments

@gomorizsolt
Copy link
Collaborator

(1) Instead of inline if conditions:

{settings.logo ? <Logo src={settings.logo} alt={settings.name} /> : null}

Use the && operator consistently(IIRC we already discussed this):

{settings.logo && <Logo src={settings.logo} alt={settings.name} />}

(2) Instead of && to ensure object fields:

{settings.header && settings.header.technologies ? (

Use the optional chaining operator:

{settings?.header?.technologies && ( ... )}

We may also find further improvements.

@thisismydesign
Copy link
Member

Feel free to do these small refactors when you notice them.

@gomorizsolt
Copy link
Collaborator Author

https://github.com/zeit/next.js/releases/tag/v9.2.0

Use optional chaining syntax: #9975

Cool! The underlying framework supports the optional chaining operator out of the box. My gut feeling, though, is that we must tweak the linter config to make it work.

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

No branches or pull requests

2 participants