Guest User

Untitled

a guest
Mar 20th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. class Columns extends React.Component {
  2. fetchCSVData = async () => { <-- this function
  3. const { ownerId } = this.props;
  4. const CSVTrackResponse = await getCSVClientReport({ ownerId });
  5. fileDownload(CSVTrackResponse, 'lifetimeTracks.csv');
  6. };
  7.  
  8. render() {
  9. const children = React.Children.map(this.props.children, child => {
  10. return React.cloneElement(child, {
  11. onDownload: () => this.fetchCSVData()
  12. });
  13. });
  14. return <ColumnsContainer>{children}</ColumnsContainer>;
  15. }
  16. }
  17.  
  18.  
  19. const Reports = ({ ownerId }) => (
  20. <Container>
  21. <Header>Reports</Header>
  22. <Columns ownerId={ownerId}> <-- this component has a inner function
  23. <Cell title="LIFETIME TRACKS" />
  24. </Columns>
  25. </Container>
  26. );
Add Comment
Please, Sign In to add comment