Skip to content

Instantly share code, notes, and snippets.

@ryardley
Last active August 4, 2016 06:36
Show Gist options
  • Save ryardley/7230648e3815daa9a90794f8a4d9b98f to your computer and use it in GitHub Desktop.
Save ryardley/7230648e3815daa9a90794f8a4d9b98f to your computer and use it in GitHub Desktop.
const Switch = (props) => <span>{props.children}</span>;
const Case = (props) => props.expr && props.children;
function TestSwitch() {
const val = 3;
return (
<Switch>
<Case expr={val === 1}>
<div>One</div>
</Case>
<Case expr={val === 2}>
<div>Two</div>
</Case>
<Case expr={val === 3}>
<div>Three</div>
</Case>
</Switch>
);
}
const elem = document.getElementById('thing');
ReactDOM.render(<TestSwitch/>, elem)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment