Skip to content

Instantly share code, notes, and snippets.

@danhab99
Created March 4, 2020 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danhab99/ee86e70fc7af1acb6587bd42551da48d to your computer and use it in GitHub Desktop.
Save danhab99/ee86e70fc7af1acb6587bd42551da48d to your computer and use it in GitHub Desktop.
A view switching component for react
/**
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