Guest User

Untitled

a guest
Jul 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. Example 1:
  2.  
  3. export const MyContent = styled.div`
  4. background-color: red;
  5. `;
  6.  
  7. export const MyContentHeader = styled.div`
  8. padding: 20px;
  9. `;
  10.  
  11. export const MyContentFooter = styled.div`
  12. margin-bottom: 20px;
  13. `;
  14.  
  15. (in use)
  16.  
  17. <MyContent>
  18. <MyContentHeader>Text goes here</MyContentHeader>
  19. <MyContentButtons>
  20. <Button>Button1</Button>
  21. <Button>Button2</Button>
  22. </MyContentButtons>
  23. </MyContent>
  24.  
  25. -------
  26.  
  27.  
  28. class MyContent extends React.Component {
  29. constructor(props) {
  30. this.state = { name: "test" };
  31. }
  32. render() {
  33. return (
  34. <div>
  35. {this.props.header(this.state)}
  36. {this.props.footer(this.state)}
  37. </div>
  38. );
  39. }
  40. }
  41.  
  42.  
  43. <MyContent
  44. header={(data) => <Header>{data.name}</Header>}
  45. footer={(props) => (
  46. <Button>Button1</Button>
  47. <Button>Button2</Button>
  48. )}
  49. />
Add Comment
Please, Sign In to add comment