Created
August 11, 2016 20:18
-
-
Save ryardley/4552819c48fbf12ab03a4ffe0826b4f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Switch = (props) => <span>{props.children}</span>; | |
const Case = (props) => props.expr && props.children; | |
const TestInstantiated = (props) => { | |
console.log(`${props.id}: I was rendered`); | |
return <div>{props.id}</div>; | |
} | |
function TestSwitch() { | |
const val = 3; | |
return ( | |
<Switch> | |
<Case expr={val === 1}> | |
<TestInstantiated id="1">One</TestInstantiated> | |
</Case> | |
<Case expr={val === 2}> | |
<TestInstantiated id="2">Two</TestInstantiated> | |
</Case> | |
<Case expr={val === 3}> | |
<TestInstantiated id="3">Three</TestInstantiated> | |
</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