Guest User

Untitled

a guest
May 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. // @flow
  2. import React,{ Component } from 'react';
  3.  
  4. type Props<T> = {
  5. fetch: () => Promise<T>,
  6. cb: T => T,
  7. };
  8.  
  9. class Client<T> extends Component<Props<T>> {
  10.  
  11. componentDidMount() {
  12. const { fetch, cb } = this.props;
  13. fetch().then(cb);
  14. }
  15.  
  16. render() {
  17. return (<div />)
  18. }
  19. }
  20.  
  21. const App = <Client
  22. fetch={ () => Promise.resolve(1) }
  23. cb={ n => 'sfd' } />;
Add Comment
Please, Sign In to add comment