Skip to content

Instantly share code, notes, and snippets.

@jurosh
Last active November 20, 2023 19:39
Show Gist options
  • Save jurosh/eb0b10cdfa45c61ba99f6a441b316c21 to your computer and use it in GitHub Desktop.
Save jurosh/eb0b10cdfa45c61ba99f6a441b316c21 to your computer and use it in GitHub Desktop.
Prettier ternaries format
// Prettier < 3
const reactRouterResult =
children && !isEmptyChildren(children)
? children
: props.match
? component
? React.createElement(component, props)
: render
? render(props)
: null
: null;
// Prettier 3.1 (Back to the old days)
const reactRouterResult =
children && !isEmptyChildren(children)
? children
: props.match
? component
? React.createElement(component, props)
: render
? render(props)
: null
: null;
// Prettier 3+ (Experimental https://github.com/prettier/prettier/pull/13183)
const reactRouterResult =
children && !isEmptyChildren(children) ? children
: props.match ?
component ? React.createElement(component, props)
: render ? render(props)
: null
: null
@jurosh
Copy link
Author

jurosh commented Nov 20, 2023

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