Last active
July 1, 2018 11:05
-
-
Save raghavgarg1257/1ad1eb6a8b61c97e6f107c8c2917fff1 to your computer and use it in GitHub Desktop.
Consider the use of `children` for wrapping everything in one component. Its very common to use this `children` prop.
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
import React, { Component } from 'react'; | |
import { Route, Switch } from 'react-router-dom' | |
// import pages | |
import Container from './Container'; | |
import Greetings from './Greetings'; | |
import Customers from './Customers'; | |
class App extends Component { | |
render() { | |
return ( | |
<Switch> | |
<Container> | |
<Route exact path="/" component={ Greetings }></Route> | |
<Route path="/customers" component={ Customers }></Route> | |
</Container> | |
</Switch> | |
); | |
} | |
} | |
export default App; |
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
import React, { Component } from 'react'; | |
export default function Container({ props }) { | |
return ( | |
<div className="wrapper-class"> | |
{ props.children } | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment