Last active
August 29, 2015 14:27
-
-
Save cpojer/efd40a8ab091fe16a2f3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function matchRoute<T>( | |
route: {name: string}, | |
map: {[key: string]: () => T} | |
): ?T { | |
return map[route.name] ? map[route.name]() : null; | |
} | |
// Usage | |
matchRoute(this.props.route, { | |
'ProfileRoute': () => <Profile {...props} />, | |
'StoryRoute': () => <Story {...props} />, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment