Created
March 4, 2020 16:41
-
-
Save danhab99/ee86e70fc7af1acb6587bd42551da48d to your computer and use it in GitHub Desktop.
A view switching component for react
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
/** | |
Component will show the view named in `current` as defined by it's corresponding attribute. | |
Usage: | |
import Switch from './switch' | |
import Main from './main_view' | |
import Secondary from './secondary_view' | |
ReactDOM.render(<Switch current="main" main={<Main />} secondary={<Secondary />} /> | |
*/ | |
function Switch(props) { | |
return props[props.current] | |
} | |
export default Switch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment