Guest User

Untitled

a guest
Nov 21st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. const Touchable = (Component, handler) => {
  2. const T = ({props, children}) => {
  3. const Instance = React.createElement(
  4. Component,
  5. {
  6. ...props,
  7. onTouchStart: (e) => handler.touchStart(e),
  8. /*more listeners*/
  9. }, children);
  10. }
  11.  
  12. return T;
  13. }
  14.  
  15. const Button = ({props, children}) => <div>…</div>;
  16.  
  17. export default Touchable(Button, {touchStart: () => {}});
  18.  
  19. <Button>Hallo</Button>
  20.  
  21. <Button onTouchStart={…}>
  22. <div>…</div>
  23. </Button>
  24.  
  25. <Button>
  26. <div onTouchStart={…}>…</div>
  27. </Button>
Add Comment
Please, Sign In to add comment