Skip to content

Instantly share code, notes, and snippets.

@markodayan
Last active February 14, 2020 20:03
Show Gist options
  • Save markodayan/4412c5e2367269ce4a76fb63cfd84f3b to your computer and use it in GitHub Desktop.
Save markodayan/4412c5e2367269ce4a76fb63cfd84f3b to your computer and use it in GitHub Desktop.
React Routing Snippets
// 1) To ensure that paths are not accidently accessed - use 'exact' attribute on a Route
<Route exact path='/' component={Dashboard} />
// 2) If Routing to a functional component, the props of it contain information about the route, check with console.log
console.log(props) // in the functional comp -> eg props.match.params to get nav params from URL path
console.log(props.match.params);
// 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment