Skip to content

Instantly share code, notes, and snippets.

@knod
Created August 2, 2018 17:17
Show Gist options
  • Save knod/e6fc7e30678f183bc3cee56775ebd2d2 to your computer and use it in GitHub Desktop.
Save knod/e6fc7e30678f183bc3cee56775ebd2d2 to your computer and use it in GitHub Desktop.
A safe way to do `<RenderIfTrue>`
// This is something we could possibly do more safely
const RenderIfTrue = function ({ shouldRender, children }) {
var ToRender = children;
if (shouldRender) {
return <ToRender />;
} else {
return null;
}
}; // End <RenderIfTrue>
<RenderIfTrue shouldRender = { current.mortgage > 0 }>
{() => { return (
<CashFlowDisplayRow
timeState = { current }
generic = { `mortgage` }>Test
</CashFlowDisplayRow>
);}}
</RenderIfTrue>
@knod
Copy link
Author

knod commented Aug 2, 2018

A safe possibility that would work with our eslint configuration.

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