Skip to content

Instantly share code, notes, and snippets.

@ShopifyEng
Created July 22, 2022 18:38
Show Gist options
  • Save ShopifyEng/03f3bcb226421df5fed98147be8fb359 to your computer and use it in GitHub Desktop.
Save ShopifyEng/03f3bcb226421df5fed98147be8fb359 to your computer and use it in GitHub Desktop.
Mastering React's Stable Values - inline-jsx.tsx
function Overview() {
const [showMore, toggleShowMore] = useReducer(false, state => !state);
let details: JSX.Element
if (showMore) {
details = (<>
<Details />
<Button onPress={toggleShowMore}>Hide Details</Button>
</>);
}
else {
details = <Button onPress={toggleShowMore}>Show Details</Button>;
}
return ... {details} ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment